Thursday, December 15, 2016

Add number of days to timestamp in MySQL

Following DATE_ADD('field_name', INTERVAL) can be used to increase the number of days in the 'field_name' in MySQL databases. 

SELECT SQL

SELECT DATE_ADD('field_name', INTERVAL 2 DAY)FROM 'table_name';

Update SQL

UPDATE 'table_name'
SET field_name= DATE_ADD('field_name' , INTERVAL 2 DAY)
WHERE 'id' = 1;

No comments:

Post a Comment