How to: |
Available Languages: reporting, Maintain
The DT functions convert an integer representing the number of days elapsed since December 31, 1899 to the corresponding date. They are useful when you are performing arithmetic on a date converted to the number of days (for more information, see DA Functions: Converting a Legacy Date to an Integer). The DT functions convert the result back to a date.
There are six DT functions; each one converts a number into a date of a different format.
Note: When USERFNS is set to LOCAL, DT functions only display a six-digit date.
function(number, output)
where:
Is one of the following:
DTDMY converts a number to a day-month-year date.
DTDYM converts a number to a day-year-month date.
DTMDY converts a number to a month-day-year date.
DTMYD converts a number to a month-year-day date.
DTYDM converts a number to a year-day-month date.
DTYMD converts a number to a year-month-day date.
Integer
Is the number of days since December 31, 1899. The number is truncated to an integer.
I8xxx, where xxx corresponds to the function DTxxx in the above list.
Is the name of the field containing the result or the format of the output value enclosed in single quotation marks. The output format depends on the function being used.
DTMDY converts the NEWF field (which was converted to the number of days by DAYMD) to the corresponding date and stores the result in NEW_HIRE_DATE:
-* THIS PROCEDURE CONVERTS HIRE_DATE, WHICH IS IN I6YMD FORMAT, -* TO A DATE IN I8MDYY FORMAT. -* FIRST IT USES THE DAYMD FUNCTION TO CONVERT HIRE_DATE -* TO A NUMBER OF DAYS. -* THEN IT USES THE DTMDY FUNCTION TO CONVERT THIS NUMBER OF -* DAYS TO I8MDYY FORMAT -* DEFINE FILE EMPLOYEE NEWF/I8 WITH EMP_ID = DAYMD(HIRE_DATE, NEWF); NEW_HIRE_DATE/I8MDYY WITH EMP_ID = DTMDY(NEWF, NEW_HIRE_DATE); END TABLE FILE EMPLOYEE PRINT HIRE_DATE NEW_HIRE_DATE BY FN BY LN WHERE DEPARTMENT EQ 'MIS' END
The output is:
FIRST_NAME LAST_NAME HIRE_DATE NEW_HIRE_DATE ---------- --------- --------- ------------- BARBARA CROSS 81/11/02 11/02/1981 DIANE JONES 82/05/01 05/01/1982 JOHN MCCOY 81/07/01 07/01/1981 MARY GREENSPAN 82/04/01 04/01/1982 SMITH 81/07/01 07/01/1981 ROSEMARIE BLACKWOOD 82/04/01 04/01/1982