Home > Database > Mysql Tutorial > 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
Release: 2023-08-29 13:53:05
forward
1070 people have browsed it

在 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)
Copy after login

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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template