Type: Function
Syntax: QUARTER([datetime])
Description: This function has two different modes of operation, based on whether an argument is provided or not. With no arguments, it returns the standard duration of a quarter in seconds (7776000
, which is based on 90 days). With a datetime argument, it returns the quarter portion (between 1 and 4) for the provided datetime
Sample usage:
QUARTER()
is equal to7776000
QUARTER(created_at)
returns the quarter of the year for thecreated_at
field valueQUARTER(DATE(2023, 08, 27))
=>3
AVG(closed_at-created_at)/QUARTER()
returns the time elapsed in quarters between the creation and closing of a record. Note that the difference between two dates (closed_at-created_at
) is always returned in seconds.created_at + 2*QUARTER()
returns thecreated_at
field value plus 2 quarters.