Using a century window

A century window is a 100-year interval, such as 1950-2049, within which any two-digit year is unique. For windowed date fields, you specify the century window start date by using the YEARWINDOW compiler option.

About this task

When the DATEPROC option is in effect, the compiler applies this window to two-digit date fields in the program. For example, given the century window 1930-2029, COBOL interprets two-digit years as follows:

  • Year values from 00 through 29 are interpreted as years 2000-2029.
  • Year values from 30 through 99 are interpreted as years 1930-1999.

To implement this century window, you use the DATE FORMAT clause to identify the date fields in your program and use the YEARWINDOW compiler option to define the century window as either a fixed window or a sliding window:

  • For a fixed window, specify a four-digit year between 1900 and 1999 as the YEARWINDOW option value.

    For example, YEARWINDOW(1950) defines a fixed window of 1950-2049.

  • For a sliding window, specify a negative integer from -1 through -99 as the YEARWINDOW option value.

    For example, YEARWINDOW(-50) defines a sliding window that starts 50 years before the year in which the program is running. So if the program is running in 2010, the century window is 1960-2059; in 2011 the century window automatically becomes 1961-2060, and so on.

The compiler automatically applies the century window to operations on the date fields that you have identified. You do not need any extra program logic to implement the windowing.

Example: century window

related references  
DATEPROC  
YEARWINDOW  
DATE FORMAT clause (COBOL for AIX Language Reference)  
Restrictions on using date fields (COBOL for AIX Language Reference)