Here is the basic problem: In the 1960s and 1970s COBOL programmers normally stored dates with only year, month, and day. Data storage was very expensive, and saving money by not storing a century seemed like a bargain. Unfortunately, many programmers still continued this practice well into the 1980s and even early 1990s.
So, what was the big deal? Well, January 1, 1999 would be stored in YYMMDD format as 990101. January 1, 2000 would be stored in YYMMDD format as 000101. Any greater than or less than comparison results between the two dates would show that 000101 is LESS than 990101.
Working-Storage for the Examples
000340 01 OLD-DATE PIC X(6).
000350 01 NEW-DATE PIC X(8).
000360 01 YEAR-CHECK PIC 99.
Reference Modification Conversion
004310
004320 MOVE OLD-DATE TO NEW-DATE(3:6).
004340 MOVE NEW-DATE(3:2) TO YEAR-CHECK.
004360 IF YEAR-CHECK > 50
004380 MOVE '19' TO NEW-DATE(1:2)
004400 ELSE
004420 MOVE '20' TO NEW-DATE(1:2)
004440 END-IF.
004440
If OLD-DATE was '990101' NEW-DATE will be '19990101'. If OLD-DATE was '000101' NEW-DATE will be '20000101'.
Note: When you check YEAR-CHECK to see what values should have a century of '19' be careful. If you have some data (such as birthdays) from the 1920s then year you check against will have to be lower than 20.
Reference Modification/Evaluate Conversion
004310
004320 MOVE OLD-DATE TO NEW-DATE(3:6).
004340 EVALUATE NEW-DATE(3:2)
004360 WHEN '97' MOVE '19' TO NEW-DATE(1:2)
004370 WHEN '98' MOVE '19' TO NEW-DATE(1:2)
004380 WHEN '99' MOVE '19' TO NEW-DATE(1:2)
004400 WHEN OTHER MOVE '20' TO NEW-DATE(1:2)
004440 END-EVALUATE.
004440
If OLD-DATE was '990101' NEW-DATE will be '19990101'. If OLD-DATE was '000101' NEW-DATE will be '20000101'.
Note: In this example only the years 97, 98, and 99 are considered to have a century of '19'. All other dates will have a century of '20'. It is very important to understand your data to know what years should have a century of '19' and what years should have a century of '20'.
Go Back to:
http://Howes-IT-Going.com
This Webpage and Contents Created by Steven C. Howes ©
Howes-IT-Going 2000-2009 All rights reserved.