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.
Table 1 shows supported comparisons for nonyear-last date fields. This table uses the following terms to describe how the comparisons are performed:
This expansion is sensitive to trigger values in the date field comparand if the DATEPROC(TRIG) compiler option is in effect.
If the DATEPROC(NOTRIG) compiler option is in effect, the comparison is performed as if the nondate operand were expanded by assuming 19 for the century part of the expanded year.
If the DATEPROC(TRIG) compiler option is in effect, the comparison is sensitive to date trigger values in the nondate operand. For alphanumeric operands, these trigger values are LOW-VALUE, HIGH-VALUE, and SPACE. For alphanumeric and numeric operands compared with windowed date fields with at least one X in the DATE FORMAT clause (that is, windowed date fields other than just a windowed year), values of all zeros or all nines are also treated as triggers. If a nondate operand contains a trigger value, the comparison proceeds as if the nondate operand were expanded by copying the trigger value to the assumed century part of the expanded year. If the nondate operand does not contain a trigger value, the century part of the expanded year is assumed to be 19.
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.
|
Windowed |
Expanded |
|
|---|---|---|---|
Nondate |
Nonwindowed | Windowed1 | Nonwindowed |
Windowed date field |
Windowed1 | Windowed | Windowed |
Expanded date field |
Nonwindowed | Windowed | Nonwindowed |
|
|||
Relation conditions can contain arithmetic expressions. For information about the treatment of date fields in arithmetic expressions, see Arithmetic with date fields.