Jump to content
Macro Express Forums

Gregorian


Dash

Recommended Posts

Hello Dash -

 

We've done the work for you within our PGM Functions Library. Here is a page from the manual that explains our take on handling date numbers:

 

 

-----------

Overview

 

We were asked numerous times by quite a few of our clients to create a set of reusable macro functions to handle date calculations and here they are. They will allow you to:

  • Convert a date string to a Julian number, numeric day-of-week, character day-of-week, or numeric day-of-year.
  • Convert today's date to a Julian number, numeric day-of-week, character day-of-week, or numeric day-of-year.
  • Convert a Julian number to a date string, numeric day-of-week, character day-of-week, or numeric day-of-year.
  • Calculate a new date by adding or subtracting days or months.
  • Calculate the difference in days between two dates.
  • Evaluate if a year number is a leap year.
  • Return a character day-of-week from a numeric day-of-week.
  • Return a character month from a numeric month.
  • Parse a day number from either a date string, Julian number, or today's date.
  • Parse a month number from either a date string, Julian number, or today's date.
  • Parse a year number from either a date string, Julian number, or today's date.
  • Reformat a user's date input string.
  • Validate both date strings and Julian numbers input by users.

The functions are all based on Julian Day numbers, which are not to be confused with Julian Dates, whose calendar ended on October 15th, 1582 when the Gregorian calendar replaced it. The Gregorian calendar is the reformed Julian calendar with the year fixed at 365 days except for leap years which contain 366 days. Leap years are years that are exactly divisible by 4 except for century years which must also be divisible by 400. This is the calendar in common use today. Dates in the Gregorian calendar are called Gregorian dates. Here are some dates and their equivalent Julian Day number.

  • March 1st, 0000 as far back as these functions go 1721120
  • January 1st, 0001 first day of the 1st century 1721426
  • October 15th, 1582 first day of Gregorian calendar 2299161
  • November 16th, 1858 nothing special, just the Julian Day: 2400000
  • February 28th, 1900 last day of month, not a leap year 2415079
  • January 1st, 1901 first day of the 20th century 2415386
  • January 1st, 2001 first day of the 21st century 2451911
  • December 31st, 9999 as far into the future as we go 5373484

We were only able to cover a span of (almost) 10,000 years from March 1, 0000 through December 31, 9999. Any dates outside this range will return an error.

 

All functions have been tested against results obtained from Microsoft Visual FoxPro and Microsoft Visual Basic. We tested hundreds of thousands of dates and numbers to confirm the accuracy of these functions.

Link to comment
Share on other sites

  • 1 month later...

1) Julian dates don't help me. I need a macro that looks at how many days are in the current year, then looks at the current date, and outputs a number for the current date that I can then add or subtract from in order to flux the specific day a file name would be for. What I need specifically is Gregorian numbering system.

 

2) Looking over the PGM functions library, theres some nice macros in there, but they are too registry intensive. I don't need macros that change anything in my registry as I need to be able to give other people macros that are not allowed to have any registry editing done on their machines. On top of that, I don't really feel that I should need to pay extra for some features that I could create on my own with time and patience.

 

So, if anyone has some infomation on a simple way to create the macro I need, I'll be working on my own *FREE* adaptation...

Link to comment
Share on other sites

I wouldn't say alot. On thinking about my gregorian date request, after a couple hours I easily created a macro for it that I am perfectly satisfied with and that other people would be able to put to use as well.

 

To be honest, I've found it more rewarding that I was able to do it without having to pay, and I was able to have it do exactly what I wanted instead of having to overly modify something that I had to slap down extra cash for.

 

I realize that PGMacros hosts this forum and its in their own best interest to push people to buy the product. Though for the time and effort that I just to create my own, I would have been one angry customer if I had gone and paid extra for it.

Link to comment
Share on other sites

Hello Dash!

 

PGMacros hosts this forum and its in their own best interest to push people to buy the product
Probably just an unfortunate phrasing on your part because I do not recall pushing anything on anybody. You did say, however:
I dread the macro I have to build to actually capture it.
I think it's just peachy-keen that you have created a function that you can use.

 

Julian dates don't help me. What I need specifically is Gregorian numbering system

You are correct Julian dates don't help you, but Julian day numbers do, which is what I attempted to explain. If I remember correctly the main difference between Gregorian and Julian day numbers is that the latter takes into account the 100 and 400 year leap-year thing. If you are working with 20th century dates, it don't mean squat.

 

Looking over the PGM functions library, theres some nice macros in there, but they are too registry intensive.

There are a few very good, logical reasons for using the Registry, not the least of which is it was put there to use. Also, it is the only built-in closet on your computer where you can put things without having to convert them first, like integer and decimal type variables. If you are going for speed and reliability, it's the only way to fly.

 

On top of that, I don't really feel that I should need to pay extra for some features that I could create on my own with time and patience.

Well, we don't think you need to pay extra either. If you can do it, and you have the time, then this is good. It is how great things are created.

 

I would have been one angry customer if I had gone and paid extra for it.

Surely you jest. Have you tried anger-management?

Link to comment
Share on other sites

Joe, Floyd and Paul have spent many hours writing the macros contained in the PGM Functions Library. You certainly could spend hours writing macros that perform the same thing using different techniques, but purchasing the PGM Functions Library can save you time. And since time is money, it is a bargain.

 

We at Insight Software Solutions would again like to thank Professional Grade Macros for their support of Macro Express including hosting this forum, writing Macro Express Explained, and offering the PGM Functions Library.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...