SelectEXTRACT(Quarterfrom'2017-07-29');+-------------------------------- ----+|EXTRACT(Quarterfrom'2017-07-29')|+---------------------------------- -----+|  "/> SelectEXTRACT(Quarterfrom'2017-07-29');+-------------------------------- ----+|EXTRACT(Quarterfrom'2017-07-29')|+---------------------------------- -----+|  ">

Home  >  Article  >  Database  >  In MySQL, how do we find which quarter is the current date or a specific given date?

In MySQL, how do we find which quarter is the current date or a specific given date?

WBOY
WBOYforward
2023-08-29 13:53:05999browse

在 MySQL 中,我们如何找到当前日期或特定给定日期的哪个季度?

We can do this by providing the unit value "quarter" to the EXARCT() function. Example is as follows -

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

The above query will give the quarter value for a particular given date.

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

The above query will give the quarter value for the current date.

The above is the detailed content of In MySQL, how do we find which quarter is the current date or a specific given date?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete