Home > Database > Mysql Tutorial > What are the different ways in MySQL to add a 'half year gap' to a date?

What are the different ways in MySQL to add a 'half year gap' to a date?

王林
Release: 2023-09-15 08:05:09
forward
541 people have browsed it

What are the different ways in MySQL to add a half year gap to a date?

We can add "half-year interval" in the date by -

(A) By adding 6 months interval

mysql> Select '2017-06-20' + INTERVAL 6 Month AS 'After Half Year Interval';
+--------------------------+
| After Half Year Interval |
+--------------------------+
|  2017-12-20              |
+--------------------------+
1 row in set (0.00 sec)
Copy after login

(B) Add an interval of 2 quarters

mysql> Select '2017-06-20' + INTERVAL 2 Quarter AS 'After Half Year Interval';
+--------------------------+
| After Half Year Interval |
+--------------------------+
| 2017-12-20               |
+--------------------------+
1 row in set (0.00 sec)
Copy after login

The above query will add a half-year interval to the date with the help of the Quarter keyword.

The above is the detailed content of What are the different ways in MySQL to add a 'half year gap' to a 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