Y4DATE
Y4DATE takes a date value with the pattern 'YYMMDD'
and
returns the date value with the two-digit year widened to a four-digit
year.
- d
- A string expression representing a date.
d must have computational type and should have character type. If not, d is converted to character.
- w
- Specifies an expression (such as 1950) that can be converted to an integer. If negative, it specifies an offset to be subtracted from the value of the year when the code runs. If omitted, w defaults to the value specified in the WINDOW compile-time option.
The returned value has the attributes CHAR(8) NONVARYING and is
calculated as follows:
dcl y2 pic'99';
dcl y4 pic'9999';
dcl cc pic'99';
y2 = substr(d,1,2);
cc = w/100;
if y2 < mod(w,100) then
y4 = 100*cc + 100 + y2;
else
y4 = 100*cc + y2;
return( y4 || substr(d,3) );
Y4DATE('990101',1950)
returns '19990101'Y4DATE('000101',1950)
returns '20000101'