Home »
MySQL »
MySQL date/time Functions
MySQL QUARTER() Function
MySQL | QUARTER() Function: Learn about the QUARTER() function, how it works, its usages, syntax, and examples.
Submitted by Apurva Mathur, on October 11, 2022
QUARTER() Function
Whenever you want to find out the quarter of the given date then in such case we use QUARTER() function.
We know that quarter means having 4 equal parts, so in total we have 12 months from which we have the following notations for the quarter:
- January, February, and March = 1
- April, May, and June = 2
- July, August, and September =3
- October, November, and December= 4
QUARTER() Syntax
SELECT QUARTER(datetime value);
QUARTER() Parameter(s)
This function takes one parameter and that is datetime value, you have to provide a date on which you want to know the quarter month.
QUARTER() Return Value
This function will return you the quarter month of the datetime value which you will provide as the parameter.
MySQL QUARTER() Function Example 1
SELECT QUARTER('2019-09-12');
Here 09 means September and according to the notation written above its quarter value is 3.
MySQL QUARTER() Function Example 2
SELECT QUARTER('2029-12-12');
Here 12 means December and according to the notation written above its quarter value is 4.
MySQL QUARTER() Function Example 3
SELECT QUARTER('2029-13-12');
Here as you can see the date is not valid therefore it will return you the NULL.