How to: |
Available Languages: reporting, Maintain
The DATECVT function converts the format of a date in an application without requiring an intermediate calculation. 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, 'infmt', {'outfmt'|outfield})
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. It is one of the following:
Format must match the format specified for the output format (outfmt).
Is the name of the field that contains the result.
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
WebFOCUS |