ILE COBOL Language Reference

+-------------------------------IBM Extension--------------------------------+


YEAR-TO-YYYY

The YEAR-TO-YYYY function converts argument-1, the two low-order digits of a year, to a four-digit year. Argument-2, when added to the year at the time of execution, defines the ending year of a 100-year interval, or sliding window, into which the year of argument-1 falls.

The type of the function is integer.

Format
 
>>-FUNCTION YEAR-TO-YYYY--(argument-1-+------------+-)---------><
                                      '-argument-2-'
 
 
argument-1
Must be a nonnegative integer that is less that 100.
argument-2
Must be an integer. If argument-2 is omitted, the function will be evaluated with a value of 50 for argument-2. At the time of execution, the sum of the year and argument-2 will be less than 10000, and greater than 1699.

In order for the compiler to calculate the FUNCTION YEAR-TO-YYYY, the ending year of the sliding window (or "maximum-year") needs to be calculated first. The "maximum-year" is calculated as follows:

(FUNCTION NUMVAL(FUNCTION CURRENT-DATE(1:4)) + argument-2)

Given that the "maximum-year" above the FUNCTION YEAR-TO-YYYY is equivalent to one of the two arithmetic expressions depending on the following condition:

maximum-year modulus 100 >= argument-1

When this condition is true, the equivalent arithmetic expression is:

(argument-1 + 100 * (truncated integer value of (maximum-year/100)))

Otherwise, the equivalent arithmetic expression is:

(argument-1 + 100 * (truncated integer value of (maximum-year/100) - 1))

The YEAR-TO-YYYY function implements a sliding window algorithm. To use it for a fixed window, argument-2 can be specified as follows, where fixed-maximum-year is the maximum year in the fixed 100-year intervals.

If the fixed window is 1973 through 2072, then in 2009 argument-2 will have the value of 63, and in 2019, the value of 53.

(fixed-maximum-year - FUNCTION NUMVAL (FUNCTION CURRENT-DATE (1:4)))

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]