The DATE-TO-YYYYMMDD function converts argument-1 from a date with a two-digit year (YYnnnn) to a date with a four-digit year (YYYYnnnn). argument-2, when added to the year at the time of execution, defines the ending year of a 100-year interval, or sliding century window, into which the year of argument-1 falls.
The function type is integer.
If the DATEPROC compiler option is in effect, the returned value is an expanded date field with implicit DATE FORMAT YYYYXXXX.
Format >>-FUNCTION DATE-TO-YYYYMMDD------------------------------------> >--(--argument-1--+------------+--)---------------------------->< '-argument-2-'
Note: The COBOL run time does not verify that the value is a valid date.
The sum of the year at the time of execution and the value of argument-2 must be less than 10,000 and greater than 1,699.
The following are examples of returned values from the DATE-TO-YYYYMMDD function:
| Current year | argument-1 value | argument-2 value | Returned value |
|---|---|---|---|
| 2002 | 851003 | 120 | 20851003 |
| 2002 | 851003 | -20 | 18851003 |
| 2002 | 851003 | 10 | 19851003 |
| 1994 | 981002 | -10 | 18981002 |