HDTTM: Converting a Date Value to a Date-Time Value

How to:

The HDTTM function converts a date value to a date-time value. The time portion is set to midnight.

Syntax: How to Convert a Date Value to a Date-Time Value

HDTTM(date, length, output)

where:

date

Date

Is the date to be converted, the name of a date field that contains the value, or an expression that returns the value. It must be a full component format date. For example, it can be MDYY or YYJUL.

length

Integer

Is the length of the returned date-time value. Valid values are:

  • 8 indicates a time value that includes milliseconds.
  • 10 indicates a time value that includes microseconds.
  • 12 indicates a time value that includes nanoseconds.
output

Date-time

Is the generated date-time value. It can be a field or the format of the output value enclosed in single quotation marks. The value must have a date-time format (data type H).

Example: Converting a Date Field to a Date-Time Field (Reporting)

HDTTM converts the date field TRANSDATE_DATE to a date-time field:

TABLE FILE VIDEOTR2
PRINT CUSTID TRANSDATE AS 'DATE-TIME' AND COMPUTE
TRANSDATE_DATE/YYMD = HDATE(TRANSDATE, 'YYMD');
DT2/HYYMDIA = HDTTM(TRANSDATE_DATE, 8, 'HYYMDIA');
WHERE DATE EQ 2000;
END

The output is:

CUSTID  DATE-TIME         TRANSDATE_DATE  DT2
------  ---------         --------------  ---
1237    2000/02/05 03:30  2000/02/05      2000/02/05 12:00AM
1118    2000/06/26 05:45  2000/06/26      2000/06/26 12:00AM