For this, you can use date_add(). Let us first create a table −
mysql> create table DemoTable1930 ( DueTime datetime ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1930 values('2017-10-21'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1930 values('2019-12-14'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1930 values('2018-11-26'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1930 values('2014-06-16'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1930;
This will produce the following output −
+---------------------+ | DueTime | +---------------------+ | 2017-10-21 00:00:00 | | 2019-12-14 00:00:00 | | 2018-11-26 00:00:00 | | 2014-06-16 00:00:00 | +---------------------+ 4 rows in set (0.00 sec)
Here is the query to add days −
mysql> select DueTime,date_add(DueTime, interval 45 day) as ManyDays from DemoTable1930;
This will produce the following output −
+---------------------+---------------------+ | DueTime | ManyDays | +---------------------+---------------------+ | 2017-10-21 00:00:00 | 2017-12-05 00:00:00 | | 2019-12-14 00:00:00 | 2020-01-28 00:00:00 | | 2018-11-26 00:00:00 | 2019-01-10 00:00:00 | | 2014-06-16 00:00:00 | 2014-07-31 00:00:00 | +---------------------+---------------------+ 4 rows in set (0.00 sec)