Y4YEAR Function

Purpose

Expands a two-digit year in format YY to a four-digit year, with the returned value in YYYY format.

Syntax

Y4YEAR (d[, w])

Parameters

d is a string expression of computational and character type with at least two characters. Characters in excess of two must be formed by leading blanks. If the character type is omitted, it is converted to character by default.

w is an integer expression value of the century window to be used for any two-digit year formats.

  • Any positive numeric value is treated as a year.
  • Negative or zero values are treated as an offset and subtracted from the current, system-supplied year.
  • If not specified, the value of w is the value specified in the -window compiler option.

Description

The Y4YEAR built-in function returns a value with the CHAR(4) NONVARYING attributes calculated as follows:

dcl y2 pic’99’;
dcl y4 pic’9999’;
dcl c pic’99’;
y2 = d;
cc = w/100;
if y2 < mod(w,100) then
y4 = 100*cc + 100 + y2;
else
y4 = 100*cc + y2;
return( y4 );

Examples

Y4YEAR('99',1975) returns '1999'

Y4YEAR('00',1975) returns '2000'

Restrictions

None.