Date field
A
date field can be any of the following:
- A data item whose data description entry includes a DATE FORMAT clause
- A value returned by one of the following intrinsic functions:
- DATE-OF-INTEGER
- DATE-TO-YYYYMMDD
- DATEVAL
- DAY-OF-INTEGER
- DAY-TO-YYYYDDD
- YEAR-TO-YYYY
- YEARWINDOW
- The conceptual data items DATE, DATE YYYYMMDD, DAY, or DAY YYYYDDD of the
ACCEPT statement
- The result of certain arithmetic operations (for details, see Arithmetic with date fields)
The term date field refers to both expanded date fields and windowed date fields.
A
windowed date field is a date field that contains a windowed year. A windowed
year consists of two digits, representing a year within the century window.
An
expanded date field is a date field that contains an expanded year. An expanded
year consists of four digits.
The main use of expanded date fields is to provide correct results when these are used
in combination with windowed date fields; for example, where migration to four-digit year
dates is not complete. If all the dates in an application use four-digit years,
there is no need to use the millennium language extensions.
A
year-last date field is a date field whose DATE FORMAT clause specifies one or
more Xs preceding the YY or YYYY. Year-last date fields are supported in a limited number
of operations, typically involving another date with the same (year-last) date
format, or a nondate.
Date
format refers to the date pattern of a date field, specified either:
- Explicitly, by the DATE FORMAT clause or DATEVAL intrinsic function argument-2
- Implicitly, by statements and intrinsic functions that return date fields
(for details, see Date field above)
The
meaning of the term compatible, when applied to date fields, depends on
the COBOL division in which the date field occurs:
- Data division
- Two date fields are compatible if they have identical USAGE and meet at
least one of the following conditions:
- They have the same date format.
- Both are windowed date fields, where one consists only of a windowed year, DATE FORMAT
YY.
- Both are expanded date fields, where one consists only of an expanded year, DATE FORMAT
YYYY.
- One has DATE FORMAT YYXXXX, the other, YYXX.
- One has DATE FORMAT YYYYXXXX, the other, YYYYXX.
A windowed date field can be subordinate to an expanded date group data item. The
two date fields are compatible if the subordinate date field has USAGE
DISPLAY, starts 2 bytes after the start of the group expanded date field, and the two
fields meet at least one of the following conditions:
- The subordinate date field has a DATE FORMAT pattern with the same
number of Xs as the DATE FORMAT pattern of the group date field.
- The subordinate date field has DATE FORMAT YY.
- The group date field has DATE FORMAT YYYYXXXX and the subordinate date field
has DATE FORMAT YYXX.
- Procedure division
- Two date fields are compatible if they have the same date format except for
the year part, which can be windowed or expanded. For example, a windowed date field
with DATE FORMAT YYXXX is compatible with:
- Another windowed date field with DATE FORMAT YYXXX
- An expanded date field with DATE FORMAT YYYYXXX
|