# D Conversion
Read Time: 4 minute(s)
Tags: date conversion
Converts dates between internal and external format. It takes the general form:
- p is the special processing operator. Can be any one of the following:
|D||Returns only the day of the month as a numeric value.|
|I||Returns only dates stored in the external format in internal format. You can use this in field 7 or 8.|
|J||Returns the Julian day (1 - 365, or 1 - 366 for a leap year).|
|M||Returns the number of the month (1 - 12).|
|MA||Returns the name of the month in uppercase letters.|
|Q||Returns the number of the quarter (1 - 4)|
|W||Returns the day of the week as a numeric value (Monday is 1).|
|WA||Returns the day of the week in uppercase letters (MONDAY - SUNDAY).|
|Y||Returns the year (up to four digits).|
- n is a number from 0 to 4 that specifies the how many digits to use for the year field. If omitted, the year will have four-digits. If n is 0, the year will be suppressed.
- s is a non-numeric character to be used as a separator between month, date, and year. Must not be one of the special processing operators.
Dates are stored internally as integers which represent the number of days (plus or minus) from the base date of December 31, 1967. For example:
|22 September 1967||-100|
|30 December 1967||-1|
|31 December 1967||0|
|01 January 1968||1|
|09 April 1968||100|
|26 September 1967||1000|
|14 January 1995||9876|
|29 February 2000||11748|
|07 January 2020||19000|
If a special processing operator, or an output separator , the default output format is two-digit day, a space, a three-character month, a space, and a four-digit year. If just an output separator is specified, the date format defaults either to the US numeric format "mm/dd/yyyy" or to the international numeric format "dd/mm/yyyy" (where / is the separator). The numeric format can be changed for the duration of a logon session with the DATE-FORMAT command.
# Pre-processor Conversion
Field 8 codes are valid but, generally, it is easier to specify the D code in field 7 for input conversion. Dates in output format are difficult to use in selection processing.
If you are going to use selection processing and you want to use a code which reduces the date to one of its parts, such as DD (day of month), the D code must be specified in field 8.
# Input/output Conversion
Field 7 input and output conversions are both valid.
Generally, for selection processing, you should specify D codes in field 7. An exception is when you use a formatting code, such as DM, that reduces the date to one of its parts.
If no year is specified in the sentence, the system assumes the current year on input conversion. If only the last two digits of the year are specified, the system assumes the following years:
00-29: 2000 - 2029
30-99: 1930 -1999
|D Code||Internal Value||Value Returned|
|D||9904||11 FEB 1995|
|DI||11 FEB 1995||9904|
Back to Conversion Processing