Restrictions on using date fields
The following sections describe restrictions on using date fields in these
contexts:
- DATE FORMAT clauses combined with other clauses
- Group items consisting only of a date field
- Language elements that treat date fields as nondates
- Language elements that do not accept date fields as arguments
For restrictions on using date fields in other contexts, see:
Combining the DATE FORMAT clause with other clauses
The following phrases are the only phrases of the USAGE clause that can be
combined with the DATE FORMAT clause:
- BINARY
- COMPUTATIONAL1
- COMPUTATIONAL-3
- COMPUTATIONAL-4
- DISPLAY
- PACKED-DECIMAL
1USAGE COMPUTATIONAL cannot be combined with the DATE FORMAT
clause if the TRUNC(BIN) compiler option is in effect.
The PICTURE character-string must specify the same number of characters or
digits as the DATE FORMAT clause. For alphanumeric date fields, the only PICTURE
character-string symbols allowed are A, 9, and X, with at least one X. For
numeric date fields, the only PICTURE character-string symbols allowed are 9 and
S.
The following clauses are not allowed for a data item defined with DATE FORMAT:
- BLANK WHEN ZERO
- JUSTIFIED
- SEPARATE CHARACTER phrase of the SIGN clause
The EXTERNAL clause is not allowed for a windowed date field or a group item that
contains a windowed date field subordinate item.
Some restrictions apply when combining the following clauses with DATE FORMAT:
Group items that are date fields
If a group item is defined with a DATE FORMAT clause, then the following
restrictions apply:
- The elementary items in the group must all be USAGE DISPLAY.
- The length of the group item must be the same number of characters as the date-pattern
in the DATE FORMAT clause.
- If the group consists solely of a date field with USAGE DISPLAY, and both
the group and the single subordinate item have DATE FORMAT clauses, then the
DATE FORMAT clauses must be identical.
- If the group item contains subordinate items that subdivide the group,
then the following restrictions apply:
- If a named (not FILLER) subordinate item consists of exactly the year
part of the group item date field and has a DATE FORMAT clause, then the
DATE FORMAT clause must be YY or YYYY with the same number of year
characters as the group item.
- If the group item is a Gregorian date with a DATE FORMAT clause of
YYXXXX, YYYYXXXX, XXXXYY, or XXXXYYYY, and a named subordinate date data
item consists of the year and month part of the Gregorian date, then its
DATE FORMAT clause must be YYXX, YYYYXX, XXYY, or XXYYYY, respectively
(or, for a group date format of YYYYXXXX, a subordinate date format of
YYXX as described below).
- A windowed date field can be subordinate to an expanded date field group item if the
subordinate item starts two characters after the group item, neither
date is in year-last format, and the date format of the subordinate item
either has no Xs or has the same number of Xs following the Ys as the
group item, or is YYXX under a group date format of YYYYXXXX.
- The only subordinate items that can have a DATE FORMAT clause are
those that define the year part of the group item, the windowed part of
an expanded date field group item, or the year and month part of a Gregorian date
group item, as discussed in the above restrictions.
For example, the following defines a valid group item:
01 YYMMDD DATE FORMAT YYXXXX.
02 YYMM DATE FORMAT YYXX.
03 YY DATE FORMAT YY PICTURE 99.
03 PICTURE 99.
02 DD PICTURE 99.
If date fields are used in the following language elements, they are treated
as nondates. That is, the DATE FORMAT is ignored, and the content of the date
data item is used without undergoing automatic expansion.
- In the environment division file-control paragraph:
- SELECT ... ASSIGN USING data-name
- SELECT ... PASSWORD IS data-name
- SELECT ... FILE STATUS IS data-name
- In data division entries:
- LABEL RECORD IS data-name
- LABEL RECORDS ARE data-name
- LINAGE IS data-name FOOTING data-name TOP data-name BOTTOM data-name
- In class conditions
- In sign conditions
- In DISPLAY statements
Windowed date fields cannot be used as:
- A data-name in the following formats of the environment division
file-control paragraph:
- SELECT ... RECORD KEY IS
- SELECT ... ALTERNATE RECORD KEY IS
- SELECT ... RELATIVE KEY IS
- A data-name in the RECORD IS VARYING DEPENDING ON clause of a data
division file description (FD) or sort description (SD) entry
- The object of an OCCURS DEPENDING ON clause of a data division data
definition entry
- The key in an ASCENDING KEY or DESCENDING KEY phrase of an OCCURS clause
of a data division data definition entry
- Any data-name or identifier in the following statements:
- CANCEL
- GO TO ... DEPENDING ON
- INSPECT
- SET
- SORT
- STRING
- UNSTRING
- In the CALL statement, as the identifier containing the program-name
- In the INVOKE statement, as the identifier specifying the object on which
the method is invoked, or the identifier containing the method name
- Identifiers in the TIMES and VARYING phrases of the PERFORM statement (windowed date fields
are allowed in the PERFORM conditions)
- An identifier in the VARYING phrase of a serial (format-1) SEARCH
statement, or any identifier in a binary (format-2) SEARCH statement (windowed date fields
are allowed in the SEARCH conditions)
- An identifier in the ADVANCING phrase of the WRITE statement
- Arguments to intrinsic functions, except the UNDATE intrinsic function
Windowed date fields cannot be used as ascending or descending keys
in MERGE or SORT statements.
Neither windowed date fields nor expanded date fields can be used:
- In the DIVIDE statement, except as an identifier in the GIVING or
REMAINDER clause
- In the MULTIPLY statement, except as an identifier in the GIVING clause
(Date fields cannot be used as operands in division or multiplication.)
|