Categories: Date/Time
WEEK
Extracts the week number (from 0 to 53) for a given date or timestamp.
Syntax
EXTRACT(WEEK FROM date_timestamp_expression string) → bigint
- date_timestamp_expression: A
DATE
orTIMESTAMP
expression.
Examples
WEEK example using a timestampSELECT EXTRACT(WEEK FROM TIMESTAMP '2019-08-12 01:00:00.123456')
-- 33
SELECT EXTRACT(WEEK FROM DATE '2019-08-12')
-- 33
SELECT EXTRACT(WEEK FROM CAST('2019-08-12 01:00:00' AS TIMESTAMP))
-- 33
Usage Notes
This function uses the EXTRACT
function. When using the CAST
function, timestamps containing milliseconds are not allowed.
Was this page helpful?
Glad to hear it! Thank you for your feedback.
Sorry to hear that. Thank you for your feedback.