Reputation: 159
I have a table containing a datetime column.
I need to add 15 hours to all these values.
e.g.
As Is: 2007-08-22 08:55:10
To Be: 2007-08-22 23:55:10
As Is: 2009-08-22 14:55:10
To Be: 2009-08-23 05:55:10
Is there a MySQL UPDATE
query that can do this?
Upvotes: 9
Views: 14689
Reputation: 1106
Given that test
is the table, date_col
is the column with the date to be updated and id
is the primary key of the test
table:
update test set date_col = ADDTIME(date_col, '15:0:0') where id=1;
tested with mysql version 5.5.4
Upvotes: 28
Reputation: 137
update table_name set column_name = ADDTIME(column_name, '15:0:0');
Upvotes: 0
Reputation: 2454
update table_name set column_name =DATE_ADD(column_name, INTERVAL 15 HOUR)
Upvotes: 8