Select'2017-06-20'+INTERVAL6MonthAS'AfterHalfYearInterval';+---------- ------------------+|AfterHalfYearInterval|+--------------------------+| 2017-12-20 &"/> Select'2017-06-20'+INTERVAL6MonthAS'AfterHalfYearInterval';+---------- ------------------+|AfterHalfYearInterval|+--------------------------+| 2017-12-20 &">

Home  >  Article  >  Database  >  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?

王林
王林forward
2023-09-15 08:05:09514browse

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)

(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)

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!

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