QUARTER() Function Examples – MySQL

QUARTER() Function Examples – MySQL

Here, we will demonstrate how to works the quarter() function of mysql and how to use this function with various examples.

MySQL QUARTER() Function

In MySQL, the QUARTER() function is used to return the quarter of the year of a given date.

Note: You can pass one parameter in these functions, this will extract the quarter from the parameter.


The syntax of the quarter() function is:


Here date is the date which you want to extract the quarter from.


Let’s take a simple and basic example of this quarter() function:

SELECT QUARTER('2019-07-21');


 | QUARTER('2019-07-21') |
 |                     3 |


Let’s take another example with the date have an out of range, in that case, you’ll get a null value:

SELECT QUARTER('2019-07-32');


| QUARTER('2019-07-32') |
|                  NULL |


Now we take the next example for the function:



| QUARTER(20190721) |
|                 3 |


Let’s see the example using curdate() function that extracts the quarter from the current date.

    CURDATE() AS 'Current Date',
    QUARTER(CURDATE()) AS 'Quarter';


| Current Date | Quarter |
| 2019-07-21   |       3 |


Next, we take an example of the database. We use the database table to fetch the data from the table using this MySQL query:

USE sakila;
    created_at AS 'Create Date',
    QUARTER(created_at) AS 'Quarter'
FROM test
WHERE id = 1;


| Created Date        | Quarter |
| 2019-07-21 11:40:47 |       3 |


Here, you have learned how to use MySQL QUARTER() function with various examples.

You may like

  1. TIMESTAMP() Function Examples – MySQL
  2. TIMEDIFF() Function Examples – MySQL
  3. SEC_TO_TIME() Function Examples – MySQL
  4. STR_TO_DATE() Function Examples – MySQL
  5. PERIOD_DIFF() Function Examples – MySQL
  6. PERIOD_ADD() Function Examples – MySQL
  7. SECOND() Function Examples – MySQL
  8. MICROSECOND() Function Examples – MySQL
  9. MAKETIME() Function Examples – MySQL
  10. Localtime() Function Examples – MySQL
  11. CURTIME() Function Examples – MySQL
  12. MySQL CURRENT TIMESTAMP Function Examples
  13. MySQL CURRENT TIME Function Examples
  14. ADDTIME() Function Examples – MySQL
  15. MINUTE() Function Examples – MySQL
  16. HOUR() Function Examples – MySQL
  17. NOW() MySQL Function | MySQL
  18. MySQL DATE() And TIME() Functions (List)
  19. TIMESTAMPADD() Function Examples – MySQL
  20. TIMESTAMPDIFF() Function Examples – MySQL

If you have any questions or thoughts to share, use the comment form below to reach us.


My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Javascript, JQuery, Laravel, Livewire, Codeigniter, Vue JS, Angular JS, React Js, WordPress, and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *