Processing two-digit-year dates

About this task

With the millennium language extensions (MLE), you can make simple changes in your COBOL programs to define date fields. The compiler recognizes and acts on these dates by using a century window to ensure consistency.

Use the following steps to implement automatic date recognition in a COBOL program:

Procedure

  1. Add the DATE FORMAT clause to the data description entries of the data items in the program that contain dates. You must identify all dates with DATE FORMAT clauses, even those that are not used in comparisons.
  2. To expand dates, use MOVE or COMPUTE statements to copy the contents of windowed date fields to expanded date fields.
  3. If necessary, use the DATEVAL and UNDATE intrinsic functions to convert between date fields and nondates.
  4. Use the YEARWINDOW compiler option to set the century window as either a fixed window or a sliding window.
  5. Compile the program with the DATEPROC(FLAG) compiler option, and review the diagnostic messages to see if date processing has produced any unexpected side effects.
  6. When the compilation has only information-level diagnostic messages, you can recompile the program with the DATEPROC(NOFLAG) compiler option to produce a clean listing.

Results

You can use certain programming techniques to take advantage of date processing and control the effects of using date fields such as when comparing dates, sorting and merging by date, and performing arithmetic operations involving dates. The millennium language extensions support year-first, year-only, and year-last date fields for the most common operations on date fields: comparisons, moving and storing, and incrementing and decrementing.

Related references  
DATEPROC  
YEARWINDOW  
DATE FORMAT clause (COBOL for Linux on x86 Language Reference)