Rational Developer for System z
COBOL for Windows, Version 7.5, Language Reference


Comparison of date fields

Date fields can be alphanumeric category, zoned decimal, or internal decimal; the existing rules for the validity and comparison type (numeric or alphanumeric) apply. For example, an alphanumeric date field cannot be compared with an internal decimal date field. In addition to these rules, two date fields can be compared only if they are compatible; they must have the same date format except for the year part, which can be windowed or expanded.

For year-last date fields, the only comparisons that are supported are IS EQUAL TO and IS NOT EQUAL TO between two year-last date fields with identical date formats, or between a year-last date field and a nondate.

Comparisons with date fields (Table 27) shows supported comparisons for nonyear-last date fields. This table uses the following terms to describe how the comparisons are performed:

Nonwindowed
The comparison is performed with no windowing, as if the operands were both nondates.
Windowed
The comparison is performed as if:
  1. Any windowed date field in the relation were expanded according to the century window specified by the YEARWINDOW compiler option, as described under Semantics of windowed date fields.
  2. Any repetitive alphanumeric figurative constant were expanded to the size of the windowed date field with which it is compared, giving an alphanumeric nondate comparand. Repetitive alphanumeric figurative constants include ZERO (in an alphanumeric context), SPACE, LOW-VALUE, HIGH-VALUE, QUOTE and ALL literal.
  3. Any nondate operands were treated as if they had the same date format as the date field, but with a base year of 1900.

The comparison is then performed according to normal COBOL rules. Alphanumeric comparisons are not changed to numeric comparisons by the prefixing of the century value.

Table 27. Comparisons with date fields
  Nondate
second operand
Windowed date field
second operand
Expanded date field
second operand
Nondate
first operand
Nonwindowed Windowed1 Nonwindowed
Windowed date field
first operand
Windowed1 Windowed Windowed
Expanded date field
first operand
Nonwindowed Windowed Nonwindowed
  1. When compared with windowed date fields, nondates are assumed to contain a windowed year relative to 1900. For details, see item 3 under the definition of “Windowed” comparison.

Relation conditions can contain arithmetic expressions. For information about the treatment of date fields in arithmetic expressions, see Arithmetic with date fields.


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)