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


Processing two-digit-year dates

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:

  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.

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 concepts
Millennium language extensions (MLE)

related tasks
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

related references
DATEPROC
YEARWINDOW
DATE FORMAT clause (COBOL for Windows Language Reference)


Terms of use | Feedback

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