ToTime

The ToTime function converts the input parameter to the time data type.

Syntax

ToTime(<string>|<date_time>|<offset_date_time>|<zoned_date_time> [, <format_mask>] )

 

The optional format parameter defines the date time formatting mask to use when converting a string to time. Refer to https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html for information regarding the allowed formatting masks.

Return Type

Time

Details

The function returns null if the input parameter cannot be converted to a time value. Any year, month, or day information is lost when converting to the time data type.

Similarly, any timezone name or offset information is truncated if include in the input parameter. Please refer to example use cases below. Consider using the offset_time data type if retaining timezone offset information is required.

Examples

select CurDateTime(),
ToTime(CurDateTime())
from Empty();

screen-shot-2016-10-20-at-9-12-52-am

eval ToTime(’23:59:59.999′, ‘HH:mm:ss.SSS’);

screen-shot-2016-10-20-at-9-12-59-am

eval ToTime(’05:40:38Z’, ‘HH:mm:ssVV’);

screen-shot-2016-10-20-at-9-13-05-am

eval ToTime(‘2014-06-17T13:22:38Z’, ‘yyyy-MM-dd”T”HH:mm:ssVV’);

screen-shot-2016-10-20-at-9-13-11-am

eval ToTime(’10:15:30+01:00[Europe/Paris]’, ‘HH:mm:ssXXXXX”[”zzz”]”’);

screen-shot-2016-10-20-at-9-13-15-am

Related Functions

ToOffsetTime