D Conversion

The D conversion converts dates to internal format and, upon output, to one of several different external formats.

Format

D [year] [{separator | subcode}]

Parameter(s)

year

A digit from 0 through 4 that specifies the number of digits used to represent the year. Zero signifies that no year is output; 4 is the default.

{separator}

Any single nonnumeric character that is used to separate the day, month, and year (if specified) on output. Usually this separator is a slash (/) or a hyphen (-).

{subcode}

Can be any of the following special date subcodes, if no separator is specified:

D

Lists only the number of the day.

J

Lists the Julian day of the year.

M

Lists only the number of the month.

MA

Lists only the name of the month.

Q

Lists only the number of the quarter.

W

Lists only the number of the day of the week (Sunday is 7).

WA

Lists only the name of the day of the week.

Y

Lists only the number of the year.

If subcode is not specified, the date format is DD MMM YYYY; if subcode is specified, the format is MM/DD/YY.

Description

Dates are almost always stored internally in a special format that uses less disk drive space than conventional date formats and makes it easier to perform arithmetic operations on this data. The internal representation of a date is the number of days before or after the zero date, which is December 31, 1967.

Date conversions are almost always located in Attribute 7 of an Attribute Definition item because it is faster for the system to convert an external date to an internally stored format once and then compare the stored date to data contained in other items of the file. It is possible, however, to specify a date conversion in Attribute 8. This causes slower processing, because the internal date of every item searched must be converted to external format. This is necessary, for example, when the selection criteria or sort keys do not contain the day, month, and year.

If only two digits of the year are specified, year 30 to 99 are stored as 1930 to 1999, and 00 to 29 are stored as 2000 to 2029.

You can also specify in the syntax line that the D conversion first do a group extraction to obtain the stored date. The syntax line in this case is:

Format

D [y] [cm] [s]

Parameter(s)

c

Any single nonnumeric character used as a delimiter to separate fields (it cannot be a system delimiter).

m

A single digit that specifies the number of fields to skip in order to extract the date. m must be specified if c is specified,

Using the D Conversion

In the following examples, listed in the table below, the data input is 7/20/94. This date is stored as 8602:

If conversion is…

Then output is…

D

20 JUL 1994

D0

20 JUL

D/

07/20/1994

D2/

07/20/94

D-

07-20-1994

DY

1994

DQ

3

DD

20

DM

7

DMA

JUL

Doing a Group Extraction with the D Conversion

In the following examples, listed in the table below, the data is stored as ABC*8602.

If conversion is…

Then output is…

D2*1

ABC*20 JUL 94

D2*1/

ABC*07/20/94

See Also

Correlatives and Conversions Reference