Skip to main content

TIME

This function parses the argument using the specified format if specified.

SYNTAX

TIME ( arg [ , <format_modifier>,  format] )  

<format_modifier> ::=
"FORMAT"

ARGUMENTS

arg
A value to be converted to a time. Valid arguments are numeric, date/time values, and strings. If a format is specified arg must be of type STRING.

format_modifier
Specifies how the format argument should be interpreted.

format
An optional string argument to specify how the arg should be interpreted.

RETURN VALUE

The formatted date of TIME data type.

Remarks

  • When the arg is a numeric it is interpreted as the number of seconds since January 1, 1970 UTC.
  • If a string is provided and "FORMAT" is not specified, the default format is "15:04:05"

Examples

This example converts the datetime object to a time.

SELECT TIME(DATETIME("2021-05-12 08:06:25")) AS TM;

Response:

TM [TIME]
08:06:25