Two functions can be used for this purpose and in these two functions we need to provide column name as parameter along with INTERVAL keyword. The function is as follows -
The syntax of this function is DATE_ADD(date, INTERVAL expression unit). This can be demonstrated with an example using data from table 'collegedetail' -
mysql> Select estb, DATE_ADD(estb, INTERVAL 10 DAY) from collegedetail; +------------+---------------------------------+ | estb | DATE_ADD(estb, INTERVAL 10 DAY) | +------------+---------------------------------+ | 2010-05-01 | 2010-05-11 | | 1995-10-25 | 1995-11-04 | | 1994-09-25 | 1994-10-05 | | 2001-07-23 | 2001-08-02 | | 2010-07-30 | 2010-08-09 | +------------+---------------------------------+ 5 rows in set (0.00 sec)
The above query adds 10 days to the date stored in the 'estb' column of the 'collegedetail' table.
The syntax of this function is ADDDATE (date, INTERVAL expression unit). This can be demonstrated with an example using data from table "collegedetail" -
mysql> Select estb, ADDDATE(estb, INTERVAL 10 DAY) from collegedetail; +------------+--------------------------------+ | estb | ADDDATE(estb, INTERVAL 10 DAY) | +------------+--------------------------------+ | 2010-05-01 | 2010-05-11 | | 1995-10-25 | 1995-11-04 | | 1994-09-25 | 1994-10-05 | | 2001-07-23 | 2001-08-02 | | 2010-07-30 | 2010-08-09 | +------------+--------------------------------+ 5 rows in set (0.00 sec)
The above query adds 10 days to the date stored in the "estb" column of the "collegedetail" table.
The above is the detailed content of How can we add days/seconds to date stored in column of MySQL table?. For more information, please follow other related articles on the PHP Chinese website!