Using Legacy Date Functions

In this section:

The legacy date functions were created for use with dates in integer, packed decimal, or alphanumeric format.

For detailed information on each legacy date function, see:

AYM: Adding or Subtracting Months

AYMD: Adding or Subtracting Days

CHGDAT: Changing How a Date String Displays

DA Functions: Converting a Legacy Date to an Integer

DMY, MDY, YMD: Calculating the Difference Between Two Dates

DOWK and DOWKL: Finding the Day of the Week

DT Functions: Converting an Integer to a Date

GREGDT: Converting From Julian to Gregorian Format

JULDAT: Converting From Gregorian to Julian Format

YM: Calculating Elapsed Months

Using Old Versions of Legacy Date Functions

The functions described in this section are legacy date functions. They were created for use with dates in integer or alphanumeric format. They are no longer recommended for date manipulation. Standard date and date-time functions are preferred.

All legacy date functions support dates for the year 2000 and later.

Using Dates With Two- and Four-Digit Years

Legacy date functions accept dates with two- or four-digit years. Four-digit years that display the century, such as 2000 or 1900, can be used if their formats are specified as I8YYMD, P8YYMD, D8YYMD, F8YYMD, or A8YYMD. Two-digit years can use the DEFCENT and YRTHRESH parameters to assign century values if the field has a length of six (for example, I6YMD). For information on these parameters, see Customizing Your Environment in the TIBCO WebFOCUS® Developing Reporting Applications manual.

Example: Using Four-Digit Years

The EDIT function creates dates with four-digit years. The functions JULDAT and GREGDT then convert these dates to Julian and Gregorian formats.

DEFINE FILE EMPLOYEE
DATE/I8YYMD = EDIT('19'|EDIT(HIRE_DATE));
JDATE/I7 = JULDAT(DATE, 'I7');
GDATE/I8 = GREGDT(JDATE, 'I8');
END
TABLE FILE EMPLOYEE
PRINT DATE JDATE GDATE
END

The output is:

      DATE    JDATE     GDATE
      ----    -----     -----
1980/06/02  1980154  19800602
1981/07/01  1981182  19810701
1982/05/01  1982121  19820501
1982/01/04  1982004  19820104
1982/08/01  1982213  19820801
1982/01/04  1982004  19820104
1982/07/01  1982182  19820701
1981/07/01  1981182  19810701
1982/04/01  1982091  19820401
1982/02/02  1982033  19820202
1982/04/01  1982091  19820401
1981/11/02  1981306  19811102
1982/04/01  1982091  19820401
1982/05/15  1982135  19820515

Example: Using Two-Digit Years

The AYMD function returns an eight-digit date when the input argument has a six-digit legacy date format. Since DEFCENT is 19 and YRTHRESH is 83, year values from 83 through 99 are interpreted as 1983 through 1999, and year values from 00 through 82 are interpreted as 2000 through 2082.

SET DEFCENT=19, YRTHRESH=83
 
DEFINE FILE EMPLOYEE
NEW_DATE/I8YYMD = AYMD(EFFECT_DATE, 30, 'I8');
END
 
TABLE FILE EMPLOYEE
PRINT EFFECT_DATE NEW_DATE BY EMP_ID
END

The output is:

EMP_ID     EFFECT_DATE    NEW_DATE
------     -----------    --------
071382660
112847612
117593129     82/11/01  2082/12/01
119265415
119329144     83/01/01  1983/01/31
123764317     83/03/01  1983/03/31
126724188
219984371
326179357     82/12/01  2082/12/31
451123478     84/09/01  1984/10/01
543729165
818692173     83/05/01  1983/05/31