Categories: Date/Time
MONTH
Extracts the month number (from 1 to 12) for a given date or timestamp.
Syntax
EXTRACT(MONTH FROM date_timestamp_expression string) → bigint
- date_timestamp_expression: A
DATE
orTIMESTAMP
expression.
Examples
MONTH example using a timestampSELECT EXTRACT(MONTH FROM TIMESTAMP '2019-08-12 01:00:00.123456')
-- 8
SELECT EXTRACT(MONTH FROM DATE '2019-08-12')
-- 8
SELECT EXTRACT(MONTH FROM CAST('2019-08-12 01:00:00' AS TIMESTAMP))
-- 8
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.