Example: century window

The following example shows (in bold) how to modify a program by using the DATE FORMAT clause to take advantage of automatic date windowing.


CBLQUOTE,NOOPT,DATEPROC(FLAG),YEARWINDOW(-60)
. . .
01  Loan-Record.
    05  Member-Number   Pic X(8).
    05  DVD-ID          Pic X(8).
    05  Date-Due-Back   Pic X(6) Date Format yyxxxx.
    05  Date-Returned   Pic X(6) Date Format yyxxxx.
. . .
    If Date-Returned > Date-Due-Back Then
       Perform Fine-Member.

There are no changes to the PROCEDURE DIVISION. The addition of the DATE FORMAT clause to the two date fields means that the compiler recognizes them as windowed date fields and therefore applies the century window when processing the IF statement. For example, if Date-Due-Back contains 100102 (January 2, 2010) and Date-Returned contains 091231 (December 31, 2009), Date-Returned is less than (earlier than) Date-Due-Back, and thus the program does not perform the Fine-Member paragraph. (The program checks whether a DVD was returned on time.)