Home > OS >  How to update a datetime column with date now but time is minus 2 hour in MySQL database
How to update a datetime column with date now but time is minus 2 hour in MySQL database

Time:03-21

I would like to update a data record in Database like an example

Original datetime: 2022-03-21 08:43:15.609 Then I wanna update, change the time is back to 120 minutes ago: 2022-03-21 06:43:15.609

Could anyone help me please, I'm new to databases so I'm a bit confused, thank you for taking the time to help me

CodePudding user response:

UPDATE table SET time_col= now()- INTERVAL 2 HOUR WHERE..;

CodePudding user response:

Check this:

UPDATE table SET column = DATE_SUB('2022-03-21 08:43:15.609',INTERVAL 2 HOUR)
  • Related