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

How to:

Available Languages: reporting

The HHMS function converts a date-time value to a time value.


Top of page

x
Syntax: How to Convert a Date-Time Value to a Time Value
HHMS(datetime, length, output)

where:

datetime

Date-time

Is the date-time value to be converted.

length

Numeric

Is the length of the returned 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

Time

Is the name of the field that contains the result or the format of the output value enclosed in single quotation marks.



Example: Converting a Date-Time Value to a Time value

The following example converts the date-time field TRANSDATE to a time field with time format HHIS:

DEFINE FILE VIDEOTR2                             
TRANSYEAR/I4 = HPART(TRANSDATE, 'YEAR', 'I4');   
END                                              
TABLE FILE VIDEOTR2                              
PRINT CUSTID TRANSDATE AS 'DATE-TIME' AND COMPUTE
TRANS_TIME/HHIS = HHMS(TRANSDATE, 8, 'HHIS');    
WHERE TRANSYEAR EQ 2000;                         
END                                              

The output is:

CUSTID  DATE-TIME         TRANS_TIME
------  ---------         ----------
1118    2000/06/26 05:45  05:45:00  
1237    2000/02/05 03:30  03:30:00  

WebFOCUS