DT_FORMAT: Converting a Date or Date-Time Value to an Alphanumeric String

How to:

DT_FORMAT converts a date or date-time value to an alphanumeric string in a specified date or date-time format. For information about date and date-time formats, see the Describing Data With WebFOCUS Language manual.

Syntax: How to Convert a Date Value to an Alphanumeric String in a Specified Date Format

DT_FORMAT(date,'date_format')

where:

date

Numeric, date, or date-time

Is the date or date-time field or value to be converted.

'date_format'

Alphanumeric literal

Is a date or date-time format that fits the input date format type, enclosed in single quotation marks.

Example: Converting Date and Date_Time Values to Alphanumeric Format

The following request converts date and date-time values to alphanumeric values with specified date and date-time formats.

DEFINE FILE VIDEOTRK
NEWDT1/A12 = DT_FORMAT(TRANSDAT,'YYMD');
NEWDT2/A30 = DT_FORMAT(DT_CURRENT_DATETIME(SECOND),'HYYMTDs');
NEWDT3/A30= DT_FORMAT('April 1, 2019','YYMDTr');
END
TABLE FILE VIDEOTRK
PRINT NEWDT1 NEWDT2 NEWDT3 
BY TRANSDAT
WHERE OUTPUTLIMIT EQ 1
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
GRID=OFF,$
END

The output is shown in the following image.