Y4JULIAN Function

Purpose

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

Syntax

Y4JULIAN (d[, w])

Parameters

d is a string expression of computational and character type with at least five characters representing a date. Characters in excess of five 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 Y4JULIAN built-in function returns a value with the CHAR(7) NONVARYING attributes calculated as follows:

dcl y2 pic’99’;
dcl y4 pic’9999’;
dcl c 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) );

Examples

Y4JULIAN('99005',1975) returns '1999005'

Y4JULIAN('00005',1975) returns '2000005'

Restrictions

None.