What are the different ways in MySQL to add ‘half year interval’ in date?

MySQLMySQLi Database

We can add ‘half year interval’ in date ith the following ways −

(A) By adding interval of 6 Months

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) By adding 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)

Above query will add half year interval in date with the help of Quarter keyword.

raja
Published on 19-Feb-2018 10:38:04
Advertisements