Home
Why Macro Express®
PGM Functions Library™ 
PGM Functions Library™ Source Code 
Downloads 
About Us
Newsgroup

  Official PayPal Seal  


Last updated

Date and Time

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

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. This is the calendar in common use today. The Gregorian calendar is a 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. Dates in the Gregorian calendar are called Gregorian dates, numbers are called Julian Day numbers. 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. The Date and Time category is comprised of thirty-three functions.

{ DateTime - Date to Julian } Converts a date string to a Julian Day number
{ DateTime - Julian to Date } Converts a Julian Day number to a date string
{ DateTime - Go Months } Calculates a new date based on the number of months input
{ DateTime - Go Days } Calculates a new date based on the number of days input
{ DateTime - Span Days } Calculates the span, or number, of days between two dates
{ DateTime - Julian to DOY } Converts a Julian Day number to a numeric day-of-year
{ DateTime - Date to DOY } Converts a date to a numeric day-of-year
{ DateTime - DOY to Date } Converts a year and a numeric day-of-year to a date string.
{ DateTime - Julian to DOW } Converts a Julian Day number to a numeric day-of-week
{ DateTime - Date to DOW } Converts a date to a numeric day-of-week
{ DateTime - Julian to Character DOW } Converts a Julian Day number to a character day-of-week
{ DateTime - Date to Character DOW } Converts a date to a character day-of-week
{ DateTime - Character DOW } Converts a day-of-week number to a character day-of-week
{ DateTime - Character Month } Converts a month number to a character month
{ DateTime - Evaluate for Leap Year } Evaluates a year to determine if it is a leap year
{ DateTime - Format Input String } Converts a date string to a formatted date string (YYYMMDD)
{ DateTime - Validate Date String } Performs a validation check on an input date string
{ DateTime - Validate Julian Number } Performs a validation check on a Julian Day number
{ DateTime - Parse Day from Date } Returns the DD part of a date string as an integer
{ DateTime - Parse Day from Julian } Returns the day-of-month from a Julian date
{ DateTime - Parse Month from Date } Returns the MM part of a date string as an integer
{ DateTime - Parse Month from Julian } Returns the month from a Julian date
{ DateTime - Parse Year from Date } Returns the YYYY part of a date string as an integer
{ DateTime - Parse Year from Julian } Returns the year from a Julian date
{ DateTime - Parse Day from Today } Returns the DD part of today as an integer
{ DateTime - Parse Month from Today } Returns the MM part of today as an integer
{ DateTime - Parse Year from Today } Returns the YYYY part of today as an integer
{ DateTime - Today to DOW } Converts today to a numeric day-of-week
{ DateTime - Today to Character DOW } Converts today to a character day-of-week
{ DateTime - Today to DOY } Converts today to a numeric day-of-year
{ DateTime - Today to Julian } Converts today to a Julian Day number
{ DateTime - Reset Defaults } Resets the Date and Time values back to their default values
{ DateTime - Set Defaults } Interactively set the Date and Time default values

Examples
{ DateTime Example - Character DOW }
{ DateTime Example - Date to Char DOW }
{ DateTime Example - Date to DOW }
{ DateTime Example - Date to DOY }
{ DateTime Example - Date to Julian }
{ DateTime Example - DOY to Date }
{ DateTime Example - Evaluate for Leap Year }
{ DateTime Example - Go Days }
{ DateTime Example - Go Months }
{ DateTime Example - Julian to Date }
{ DateTime Example - Span of Days }
{ DateTime Example - Today Calculations }


Next: String Functions