Skip to main content
Version: current [24.3.x]

QUARTER

Categories: Date/Time

QUARTER

Extracts the quarter number (from 1 to 4) for a given date or timestamp.

Syntax

EXTRACT(QUARTER FROM date_timestamp_expression string) → bigint

  • date_timestamp_expression: A DATE or TIMESTAMP expression.

Examples

QUARTER example using a timestamp
SELECT EXTRACT(QUARTER FROM TIMESTAMP '2019-08-12 01:00:00.123456')
-- 3
QUARTER example using a date
SELECT EXTRACT(QUARTER FROM DATE '2019-08-12')
-- 3
QUARTER example using the CAST function
SELECT EXTRACT(QUARTER FROM CAST('2019-08-12 01:00:00' AS TIMESTAMP))
-- 3

Usage Notes

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