TIME scalar function¶
Constructs a TIME from the specified hours, minutes and seconds, or seconds from midnight.
Prototypes¶
TIME(AHOUR INTEGER, AMINUTE INTEGER, ASECOND INTEGER)
TIME(ASECONDS BIGINT)
TIME(ASECONDS INTEGER)
RETURNS TIME
Description¶
Returns a TIME with the components specified by AHOUR, AMINUTE and
ASECOND in the first case. In the second case, returns a TIME ASECONDS
after midnight. If ASECONDS represents a period longer than a day, the
value used is ASECONDS mod 86400
(the “date” portion of the seconds
value is removed before calculation). This function is essentially the reverse
of the MIDNIGHT_SECONDS function.
Parameters¶
- AHOUR
- If provided, specifies the hour component of the resulting TIME.
- AMINUTE
- If provided, specifies the minute component of the resulting TIME.
- ASECONDS
- If AHOUR and AMINUTE are provided, specifies the second component of the resulting TIME. Otherwise, specifies the number of seconds after minute from which the hour and minute components will be derived.
Examples¶
Construct a time representing midnight:
VALUES TIME(0);
1
--------
00:00:00
Construct a time representing half past noon:
VALUES TIME(12, 30, 0);
1
--------
12:30:00
See Also¶
- Source code
- DATE scalar function
- TIME (built-in function)
- MIDNIGHT_SECONDS (built-in function)