date_to_number()

Purpose

Converts date to number

Old name

#define date_2_number date_to_number

Syntax

long date_to_number(date)

Parameters

datetype* date

Pointer to date to convert

Description

The date_to_number() function converts a date to the number of days since 01 Mar 1980. It works on dates from 01 March 1600 to 31 December 9999 and uses the Gregorian calendar. It does not take account of changes in the Julian calendar which took place in English speaking countries in 1752 and in 1570 in Catholic countries.

This function is useful for avaluating the day of the week of any date. ((date_to_number(&date) % 7) +6) % 7) is 0 for Sunday through to 6 for Saturday.

Some software, especially on Unix, calculates dates and times as a number of seconds since 1 January 1970. This is day number -3712 so you can create a Unix time froma date using (date_to_number(&date)-3712)*3600*24.

Return values

Returns the number of days. (Remember that this is a long integer).