[SOLVED] How to update a datetime column with date now but time is minus 2 hour in MySQL database

Issue

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

Solution

Check this:

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

Answered By – Ibrahim Hammed

Answer Checked By – Pedro (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.