Extracts the hour number (from 0 to 23) for a given time or timestamp.
Last updated 2 years ago
Was this helpful?
date_timestamp_expression: A TIME, TIMESTAMP, or DATE expression.
TIME
TIMESTAMP
DATE
Examples
SELECT EXTRACT(HOUR FROM TIMESTAMP '2019-08-12 01:10:30.123456') -- 1
SELECT EXTRACT(HOUR FROM TIME '01:10:30.123456') -- 1
SELECT EXTRACT(HOUR FROM CAST('2019-08-12 01:10:30' AS TIMESTAMP)) -- 1
This function uses the function. When using the function, timestamps containing milliseconds are not allowed.
EXTRACT
CAST