To answer your first question — there isn’t any “good” way. The problem has to do with months and days. Is 03/04/2008 March 4 2008 (mm/dd/yy) or is it April 3 2008 (dd/mm/yy)? Both usage styles are quite valid and represent the preferred format for a date in various cultures. So a significant portion of each month (the first 12 days if you will of every month) cannot be tested with certainty.
As to adding 60 days to a date, the below should do the trick:
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Some-Date PIC X(10) VALUE "03/04/2008".
01 A-Date-Field FORMAT DATE "%m/%d/@Y".
PROCEDURE DIVISION.
MAIN-LINE.
MOVE FUNCTION CONVERT-DATE-TIME(Some-Date DATE "%m/%d/@Y")
TO A-Date-Field.
DISPLAY A-Date-Field.
MOVE FUNCTION ADD-DURATION(A-Date-Field DAYS 60)
TO A-Date-Field.
DISPLAY A-Date-Field.
STOP RUN.
There are also other intrinsic functions, such as TEST-DATE-TIME but, as mentioned above, they are more oriented to testing the values given a format — and you don’t have a good reliable way of testing the format when month and day values overlap. These functions can be found in the ILE COBOL Reference.
Bruce Vining
Discuss This Question: