MySQL QUARTER() Function
In MySQL, the QUARTER() function returns the quarter of the year for a specified date.
QUARTER() Syntax
Here is the syntax of MySQL QUARTER() function:
QUARTER(date)
Parameters
date- Required. A date or datetime expression.
Return value
The MySQL QUARTER() function returns the quarter of the year for a specified date. QUARTER(). It returns a number in the range from 1 to 4, and their meanings are as follows:
1- The first quarter, from January to March.2- The second quarter, from April to June.3- The third quarter, from July to September.4- The fourth quarter, from October to December.
The QUARTER() function will return NULL if the argument is NULL.
QUARTER() Examples
Here are some examples of the QUARTER() function.
SELECT
QUARTER('2022-02-28'),
QUARTER('2022-02-28 10:11:12');
+-----------------------+--------------------------------+
| QUARTER('2022-02-28') | QUARTER('2022-02-28 10:11:12') |
+-----------------------+--------------------------------+
| 1 | 1 |
+-----------------------+--------------------------------+