TIMETOTS: Converting a Time to a Timestamp

How to:

The TIMETOTS function converts a time to a timestamp, using the current date to supply the date component of its value. The first argument must be in H (date-time) format. The DATE component will be set to the current date.


Top of page

x
Syntax: How to Convert a Time to a Timestamp
TIMETOTS (time, length, outfield)

where:

time

Date-time

Is the time in a date-time format.

length

Integer

Is the length of the result. This can be one of the following:

8 for time values including milliseconds.

10 for input time values including microseconds.

outfield

Date-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 Time to a Timestamp

TIMETOTS converts a time argument to a timestamp:

DEFINE FILE T
TSTMPSEC/HYYMDS = TIMETOTS(TMSEC, 8, 'HYYMDS');
TSTMPMILLI/HYYMDm = TIMETOTS(TMMILLI, 10, 'HYYMDm');
END
TABLE FILE T
PRINT TMSEC TSTMPSEC TMMILLI TSTMPMILLI;
END

The output is similar to the following:

TMSEC 
TSTMPSEC
TMMILLI
TSTMPMILLI
01:02:03
11:22:33
2000-10-22 01:02:03
2000-10-22 11:22:33
01:02:03.456789
11:22:33.444444
2000-10-22 01:02:03.456789
2000-10-22 11:22:33.444444

Information Builders