This tutorial explains how to use the MySQL QUARTER function with syntax and examples.
The MySQL QUARTER function returns the quarter portion of a date value.
The syntax for the QUARTER function in MySQL is:
QUARTER( date_value )
A date or datetime value from which to extract the quarter.
The QUARTER function can be used in the following versions of MySQL:
Let's look at some MySQL QUARTER function examples and explore how to use the QUARTER function in MySQL.
For example:
mysql> SELECT QUARTER('2014-01-28');
Output: 1
mysql> SELECT QUARTER('2014-01-28 15:21:05');
Output: 1
mysql> SELECT QUARTER('2013-04-20');
Output: 2
mysql> SELECT QUARTER('2013-07-16');
Output: 3
mysql> SELECT QUARTER('2013-10-15');
Output: 4
This last QUARTER example would display the quarter portion of the current system date (current system date is returned by the CURDATE function).
mysql> SELECT QUARTER(CURDATE());