Data type Date Foundation

The "date" data type identifies values representing calendar dates. A date value cannot be written as a literal within program code. It is defined as a character string in date format which is converted to a date value using the function CtoD().

The characters used for date value are the digits 0 to 9 and a separating character dependent on the current SET DATE format. The default date format depends on the country specific Xbase++ version.

If the American date format is set, a date value in the format "MM/DD/YY" or "MM/DD/YYYY" must be specified. DD stands for the calendar day and must be between 01 and 31. MM represents the calendar month and must be between 01 to 12. YY is the year number which may be between 00 and 99. The separating character is the forward slash. If the date format is specified in the form YYYY, the century is included and the year lies between 1 and 9999. The valid range for date values is from 01/01/0001 to 12/31/9999.

today's calendar exists only since the year 1582 when Pope Gregor XIII corrected an 11 minutes error per year in the Julian calendar. Since then, February 29th does not exist in years representing a full century, except when the century is divisible by 400 (1900 was not a leap year, but 2000 was a leap year). This must be taken into consideration when calculations are computed with historical date values.

An empty date is created by passing a null string to the function CtoD(). The following shows valid date values:

CtoD("12/06/94") 
CtoD('06/25/1492') 
CtoD('01/01/1800') 
CtoD("")                   // Empty date 

The conversion of a character string to a date value automatically includes a test to check whether the date is valid. The characters "04/31/95" and "02/29/94" represent invalid dates since the month of April has only 30 days and the year 1994 was not a leap year. In this case an empty date is created.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.