How to Specify the Century for a Two-Digit Year Using the VISION:Report QUIKDATE Routine.
The VISION:Report QUIKDATE routine has 14 functions to perform a variety of date calculations and conversions:
Function 00 - Call QUIKDATE from a COBOL program
Function 01 - Convert Julian date to Calendar date
Function 02 - Convert Calendar date to Julian date
Function 03 - Compute number of days between two dates
Function 04 - Convert a date to a day of the week
Function 05 - Compute month ending date for a given date
Function 06 - Compute number of days left in a calendar month
Function 07 - Compute week ending date for a given date
Function 08 - Adjust a date up or down
Function 09 - Convert a two-digit month code to alphabetic month
Function 10 - Compute number of work days between two dates
Function 11 - Checks for holiday and time off
Function 12 - Load another date table
Function 13 - Provide date of the first working date of the month
Some of these functions require a 4-digit year as input. However, sometimes your user data may only include a 2 digit year.
To create a 4-digit year from 2-digit input, some method must exist to provide the left-most 2 digits (the century portion) of the year.
The QUIKDATE routine provides the capability of specifying the first two characters, the century portion, of a 4-character year.
This capability is in the form of an optional century parameter for all functions using a two character input date mask.
This optional parameter (19 or 20) is used as input to a QUIKDATE function (01 11). The function can then produce output
having a 4-character year or use the 4-digit year within its internal calculations.
Statement description:
CALL QUIKDATE FUNCTION 1st DATE 1st MASK 2nd DATE 2nd MASK RETURN AREA OPTIONAL CENTURY PARAMETER
Example:
CALL QUIKDATE C'03' PRT50 C'YYDDD ' PRT80 C'YYMMDD ' WST15 C'NN'*
*Where NN is 19 or 20 to indicate the century.
The Optional Century Parameter contains the 2-digit century.
In addition to the Optional Century Parameter on the CALL statement, two factors in the QUIKDATT table influence QUIKDATE's
choice of century. The QUIKDATT table is created with the WEEKDAY, HOLIDAY and WINDOW Macros. Generally speaking the
QUIKDATT table is created during the product installation process, but it can be recreated at any time. The QUIKDATT table will:
- Contain a hard-coded default century value
OR
- Specify that QUIKDATE should use an Windowing Technique in determining the century.
If both a hard-coded default century value and a Windowing Technique are specified for the QUIKDATT table,
the Windowing Technique will take precedence.
Hard-Coded Default Century Value in the QUIKDATT Table
The HOLIDAY macro allows you to specify a default value for the century (19 or 20).
Use the CHAR2 and CHAR4 parameters with values of 19 or 20 on the first Holiday statement to specify the default values
for the century when it is necessary to expand a 2-character date to a 4-character date format. Function 1 uses the value in
CHAR4. Functions 2-11 use the value in CHAR2. Note: The default values for CHAR2 and CHAR4, as shipped, are both "20".
Example:
HOLIDAY DATE=01012003,DAYLEN=WHOLE,CHAR2=20,CHAR4=20
Century Value Determined By a Windowing Technique Specified in the QUIKDATT Table
The WINDOW macro allows a 100-year interval windowing technique. Changing this macro will have a global effect over all uses of QUIKDATE.
The two types of windowing techniques are:
The Fixed-Window Technique uses a static 100-year interval that generally crosses a century boundary. This technique determines the century of a 4-digit year by comparing the 2-digit year against a window of 100 years. You specify the number of years in the past and future, relative to a fixed or specific year within the 100-year interval.
The pertinent parameters in the WINDOW macro are:
FXYEAR (Fixed specific year): If this parameter is coded, then the windowing technique is fixed. The century will be hard-coded. If FXYEAR is omitted, then the system date year is obtained from the operating system and the windowing technique is sliding.
PASTYRS: This is the window for nn past years, relative to the FXYEAR if it is coded or relative to the system date year if FXYEAR is omitted. This parameter, along with +1 for the current year, plus FUTRYRS, must add up to a 100-year interval.
FUTRYRS: This is the window for nn future years, relative to the FXYEAR if it is coded or relative to the system date year if FXYEAR is omitted. This parameter, along with +1 for the current year, plus PASTYRS, must add up to a 100-year interval.
For example, if the years of date-related data of your application fall in the range of January 1, 1960, to December 31, 2059, you can use a 2-digit year to distinguish dates prior to the year 2000 from the year 2000 and beyond. If you use the fixed year of 1995, code the number of years in the past and future as 35, in PASTYRS and 64 in FUTRYRS parameters, and code FXYEAR as 1995. QUIKDATE then determines the century based on the following program logic and data checking, assuming xx in the original 2 digit date:
xx >= 60, it is a 20th century date (19xx).
xx <= 59, it is a 21st century date (20xx).
The Sliding-Window Technique uses a self-advancing 100-year interval that generally crosses a century boundary. This technique determines the century of a 2-digit year by comparing the 2-digit year against a window of 100 years. You specify the number of years in the past and future relative to the system year (generally the current year) that the system sets and maintains. QUIKDATE can access the date that the system sets and automatically advances. The principal CA of this method over a fixed window is that the sliding window does NOT have to be manually changed each year.
For example, the years of date-related data of your application fall in the range of 43 years in the past and 56 years into the future. You code 43 in the PASTYRS parameter and 56 in the FUTRYRS parameter. Based on the system current date year, 2003, QUIKDATE can accept and accurately deal with dates of 1960 through 2059.
QUIKDATE then determines the century based on the following program logic and data checking, assuming xx in the 2 digit date:
xx >= 60, it is a 20th century date (19xx).
xx <= 59, it is a 21st century date (20xx).
Sample statements for the WINDOW macro:
WINDOW PASTYRS=43,FUTRYRS=56 Sliding Window Technique
WINDOW PASTYRS=35,FUTRYRS=64,FXYEAR=1995 Fixed Window Technique
Note: This article discusses techniques for handling 2-digit years as 4-digit years, but it is best to convert date fields with 2-digit years to date fields with 4-digit years.
Order of Precedence
So far we have discussed the three factors that influence QUIKDATE's choice of century. They are:
We have described how these factors individually affect QUIKDATE. But how does QUIKDATE choose between these factors if more than one is specified? For instance, if the CALL Statement contains the Optional Century Parameter and the QUIKDATT Table is setup for a Windowing Technique, which one does QUIKDATE choose to honor in its choice of century? The Order of Precedence, in major to minor sequence, is:
So the answer to our question above is that QUIKDATE will determine the century utilizing the Windowing Technique instead of using the Optional Century Parameter on the CALL Statement.
The Order of Precedence is somewhat counter intuitive. To circumvent this, you can create your own QUIKDATT table omitting the Windowing Technique and then load it at execution time using Function 12. In this fashion, you can control the factors that influence QUIKDATE's choice of century. Make certain that you give your table a name other than QUIKDATT, so that the system QUIKDATT table remains intact. Changing the system QUIKDATT table may affect all VISION:Report programs using QUIKDATE.
A Custom Modification, in the form of a Patch to QUIKDATE, is available to alter the Order of Precedence, in major to minor sequence, to:
The Custom Modification can be found in the VISION:Report Sample Programs Library. For Release 16.1, it is member PCP0220.
Be aware, if you apply this Custom Modification to QUIKDATE, all VISION:Report programs using QUIKDATE may be affected.