QUARTER returns the quart of the year in which the day is found, as an integer from 1 to 4, and where the first quarter of the year is “1”.

Syntax

QUARTER(expression)

Arguments

expression: a DATE, TIMESTAMP, or non-LONG VARCHAR string value that is properly formatted to represent a DATE or TIMESTAMP.

Returns

  • An INTEGER representing the quarter, between 1 and 4. Returns NULL when expression is NULL.

Examples

SELECT orderDate, QUARTER(orderDate) AS orderDateQuarter FROM MYSQL.inventory.cust;

VALUES QUARTER(CAST('2012-06-20' AS TIMESTAMP))
-- Returns 2

VALUES QUARTER(CAST('2012-12-03' AS TIMESTAMP))
-- Returns 4