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.
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
The following special codes are recognised as part of the D conversion code for ISO8601 format output. These may not be used with any other conversion elements:
Four digit year number, two digit ISO week number, one digit day of week.
Four digit year number, two digit ISO week number, one digit day of week with hyphen separators.
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 letters 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.
The date conversion system allows some flexibility to the order in which the components of the date may occur in the input data. Where an alphabetic month name is used, this is processed first. Numeric components are then assumed to be in the order of the remaining elements of the conversion code. Thus with a code of DDMY, '1 Jun 94' and 'Jun 1 94' would both convert to 9649, the internal representation of 1 June 1994.
A date that is entered as a simple digit sequence with no separators (e.g. 020609) will be treated as being day, month and year components in the order defined by the fmt element of the conversion code, with a maximum of two digits in the day and month. The year component will be processed as having the number of digits in the conversion code, defaulting to 4. A trailing year with only two digits will follow the normal rules as described in the next paragraph.
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 mode of the OPTION command.
Alphabetic Day and Month Names
The strings used for the alphabetic day and month names are derived from the QM messages file and can be different based on language selection. The relevant message numbers are
In addition, message 1502 defines the ordinal numeric strings used by the DO code.
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.
See also: |