Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


Manipulating literals as dates

If a windowed date field has a level-88 condition-name associated with it, the literal in the VALUE clause is windowed against the century window of the compile unit rather than against the assumed century window of 1900-1999.

For example, suppose you have these data definitions:

05  Date-Due        Pic 9(6)  Date Format yyxxxx.
    88  Date-Target           Value 081220.

If the century window is 1950-2049, and the contents of Date-Due are 081220 (representing December 20, 2008), then the first condition below evaluates to true, but the second condition evaluates to false:

If Date-Target. . .
If Date-Due = 081220

The literal 081220 is treated as a nondate; therefore it is windowed against the assumed century window of 1900-1999, and represents December 20, 1908. But where the literal is specified in the VALUE clause of an level-88 condition-name, the literal becomes part of the data item to which it is attached. Because this data item is a windowed date field, the century window is applied whenever it is referenced.

You can also use the DATEVAL intrinsic function in a comparison expression to convert a literal to a date field. The resulting date field will be treated as either a windowed date field or an expanded date field to ensure a consistent comparison. For example, using the above definitions, both of the following conditions evaluate to true:

If Date-Due = Function DATEVAL (081220 “YYXXXX”)
If Date-Due = Function DATEVAL (20081220 “YYYYXXXX”)

With a level-88 condition-name, you can specify the THRU option on the VALUE clause, but you must specify a fixed century window on the YEARWINDOW compiler option rather than a sliding window. For example:

05  Year-Field  Pic 99  Date Format yy.
    88 In-Range         Value 98 Thru 06.

With this form, the windowed value of the second item in the range must be greater than the windowed value of the first item. However, the compiler can verify this difference only if the YEARWINDOW compiler option specifies a fixed century window (for example, YEARWINDOW(1940) rather than YEARWINDOW(-68)).

The windowed order requirement does not apply to year-last date fields. If you specify a condition-name VALUE clause with the THROUGH phrase for a year-last date field, the two literals must follow normal COBOL rules. That is, the first literal must be less than the second literal.

related concepts
Assumed century window
Treatment of nondates

related tasks
Controlling date processing explicitly


Terms of use | Feedback

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