How to: |
Available Languages: reporting, Maintain
The DATECVT function converts the field value of any standard date format or legacy date format into a date format (offset from the base date), in the desired standard date format or legacy date format. If you supply an invalid format, DATECVT returns a zero or a blank.
DATECVT turns off optimization and compilation.
Note: You can use simple assignment instead of calling this function.
DATECVT(date, 'in_format', output)
where:
Date
Is the date to be converted. If you supply an invalid date, DATECVT returns zero. When the conversion is performed, a legacy date obeys any DEFCENT and YRTHRESH parameter settings supplied for that field.
Alphanumeric
Is the format of the date enclosed in single quotation marks. It is one of the following:
Alphanumeric
Is the output format enclosed in single quotation marks or a field containing the format. It is one of the following:
DATECVT converts 19991231 to 311299 and stores the result in CONV_FIELD:
CONV_FIELD/DMY = DATECVT(19991231, 'I8YYMD', 'DMY');
or
ONV_FIELD/DMY = DATECVT('19991231', 'A8YYMD', 'DMY');
DATECVT converts HIRE_DATE from I6YMD legacy date format to YYMD date format:
TABLE FILE EMPLOYEE PRINT FIRST_NAME AND HIRE_DATE AND COMPUTE NEW_HIRE_DATE/YYMD = DATECVT(HIRE_DATE, 'I6YMD', 'YYMD'); BY LAST_NAME WHERE DEPARTMENT EQ 'MIS'; END
The output is:
LAST_NAME FIRST_NAME HIRE_DATE NEW_HIRE_DATE --------- ---------- --------- ------------- BLACKWOOD ROSEMARIE 82/04/01 1982/04/01 CROSS BARBARA 81/11/02 1981/11/02 GREENSPAN MARY 82/04/01 1982/04/01 JONES DIANE 82/05/01 1982/05/01 MCCOY JOHN 81/07/01 1981/07/01 SMITH MARY 81/07/01 1981/07/01