Skip to main content

Categories: Date/Time

SECOND

Extracts the second number (from 0 to 59) for a given date or timestamp.

Syntax

EXTRACT(SECOND FROM date_timestamp_expression string) → bigint

  • timestamp_expression: A TIME, TIMESTAMP, or DATE expression.

Examples

SECOND example using a timestamp
SELECT EXTRACT(SECOND FROM TIMESTAMP '2019-08-12 01:10:30.123456')
-- 1
SECOND example using a time
SELECT EXTRACT(SECOND FROM TIME '01:10:30.123456')
-- 1
SECOND example using the CAST function
SELECT EXTRACT(SECOND FROM CAST('2019-08-12 01:10:30' AS TIMESTAMP))
-- 1

Usage Notes

This function uses the EXTRACT function. When using the CAST function, timestamps containing milliseconds are not allowed.