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
- 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 withDATE FORMAT
clauses, even those that are not used in comparisons. - To
expand dates, use
MOVE
orCOMPUTE
statements to copy the contents of windowed date fields to expanded date fields. - If necessary, use the
DATEVAL
andUNDATE
intrinsic functions to convert between date fields and nondates. - Use the
YEARWINDOW
compiler option to set the century window as either a fixed window or a sliding window. - 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. - 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.
Resolving date-related logic problems
Using year-first, year-only, and year-last date fields
Manipulating literals as dates
Performing arithmetic on date fields
Controlling date processing explicitly
Analyzing and avoiding date-related diagnostic messages
Avoiding problems in processing dates
DATEPROC
YEARWINDOW
DATE FORMAT clause (COBOL for Linux on x86 Language Reference)