Date Conversion (D) |
![]() ![]() ![]() |
Inside QM, dates are stored as a number of days since 31 December 1967 (day zero). All dates after that point are represented by positive numbers. All dates before that point are represented by negative numbers. This form of date is used by all multivalue databases and means that they had no issue with the millennium (day 11689). The multivalue world had its own date crisis on 18 May 1995 (day 10000) when developers discovered that they had stored the date as four characters of a composite record id or were sorting dates as character strings rather than numbers such that 17 May 1985 (day 9999) came after 18 May 1995. This potential problem still applies to any application that handles historic dates but the advantages of working with a simple day number internally far outweigh any disadvantages.
The date conversion code converts a date from its internal day number to one of a number of external formats or vice versa.
The full format of this conversion code is
D {y} {c} {fmt} {[f1, f2, f3, f4, f5]}
where
Output Conversion of Dates
The following examples show the result of output conversion of a value of 9649 with various conversion codes. Where affected by DATE.FORMAT setting, both forms are shown.
Input Conversion of Dates
Alphabetic month names may be supplied in the external format date. At least three letter must be present and conversion is not case sensitive. If more than three letters are present, the must correctly match the spelling of the month name. Where an alphabetic month name is used, the day and month fields of the external format date may be interchanged. Thus '1 Jun 94' and 'Jun 1 94' would both convert to 9649, the internal representation of 1 June 1994.
For dates entered as two digits, year number values in the range 30 to 99 are assumed to be 1930 to 1999 and 0 to 29 are assumed to be 2000 to 2029. This 100 year window can be moved using the YEARBASE configuration parameter.
Where not included, the day number or month number is assumed to be one and the year number to be the current year.
For compatibility with Information style multivalue products, a day number that exceeds the number of days in the month will roll forward into the next month and return a value of 3 from the STATUS() function. This feature can be suppressed by enabling the NO.DATE.WRAPPING option.
Calendar Differences
The process of converting an external format date to its internal day number and vice versa is not as easy as it sounds. As well as the slightly complex rules that determine which years are leap years and hence have 29 days in February, there is a problem of calendar differences. Most of the world now uses the same calendar for business purposes but this has not always been the case. There were two significant realignments, one in 1752 and an earlier one in 1583 in different parts of the world. Prior to these changes, the date in one country could be several days different from that elsewhere.
The QM date conversion operations assume the current calendar system and make no adjustment to handle these realignments. Some multivalue products implement one or other realignment. Whichever system is used, it will be incorrect in some contexts. Users who require specific handling of these changes or need to handle dates before 1 January 0001 will need to develop their own date conversion functions. |