In MySQL, how can we find which quarter is going on from current date or particular given date?


We can do it by providing unit value ‘quarter’ to EXTARCT() function. Examples are as follows −

mysql> Select EXTRACT(Quarter from '2017-07-29');
+------------------------------------+
| EXTRACT(Quarter from '2017-07-29') |
+------------------------------------+
|                                  3 |
+------------------------------------+
1 row in set (0.00 sec)

Above query will give the value of quarter from a particular given date.

mysql> Select EXTRACT(Quarter from now());
+-----------------------------+
| EXTRACT(Quarter from now()) |
+-----------------------------+
|                           4 |
+-----------------------------+
1 row in set (0.00 sec)

Above query will give the value of quarter from the current date.

Updated on: 20-Jun-2020

55 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements