Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I minus 2 hours from a date/time field in EVERY record in a table?

Tags:

sql

mysql

I'm trying to offset a timezone error from PHP. All times recorded in table 'test' was ahead by two hours. What I want is to update each record by minusing two hours from the time that is already there.

I tried:

UPDATE test 
   SET LastModifiedDate = SUBTIME( LastModifiedDate, '02:00:00' ) 

But this just updates all fields with the same value.

Please assist

tthanks

like image 949
sqluf Avatar asked Jul 15 '11 18:07

sqluf


1 Answers

update test set LastModifiedDate = LastModifiedDate - interval 2 hour;
like image 97
Nicola Cossu Avatar answered Oct 14 '22 15:10

Nicola Cossu