Semantics of windowed date fields

Windowed date fields undergo automatic expansion relative to the century window when they are used as operands in arithmetic expressions or arithmetic statements. However, the result of incrementing or decrementing a windowed date is still treated as a windowed date for further computation, comparison, and storing.

When used in the following situations, windowed date fields are treated as if they were converted to expanded date format:

  • Operands in subtractions in which the other operand is an expanded date
  • Operands in relation conditions
  • Sending fields in arithmetic or MOVE statements

The details of the conversion to expanded date format depend on whether the windowed date field is numeric or alphanumeric.

Given a century window starting year of 19nn, the year part (yy) of a numeric windowed date field is treated as if it were expanded as follows:

  • If yy is less than nn, then add 2000 to yy.
  • If yy is equal to or greater than nn, then add 1900 to yy.

For signed numeric windowed date fields, this means that there can be two representations of some years. For instance, windowed year values 99 and -01 are both treated as 1999, since 1900 + 99 = 2000 + -01.

Alphanumeric windowed date fields are treated in a similar manner, but use a prefix of 19 or 20 instead of adding 1900 or 2000.

For example, when used as an operand of a relation condition, a windowed date field defined by:


01  DATE-FIELD  DATE FORMAT YYXXXX PICTURE 9(6)
                VALUE IS 450101.

is treated as if it were an expanded date field with a value of:

  • 19450101, if the century window starting year is 1945 or earlier
  • 20450101, if the century window starting year is later than 1945