MySQL QUARTER() Function

MySQL QUARTER() Function

MySQL QUARTER() function; In this tutorial, we will demonstrate how to use MySQL quarter() function with the help of 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.

Recommended MySQL Tutorials

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


Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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