SQL reduce post date and time by 8 hours

Viewed 31

I would like to know how to write and run a SQL query to reduce 8 hours from the published time of all posts in a table please.

I need it to also properly change the date, not just the time please.

I will run it via phpMyAdmin.

  • Table name: my_posts
  • Column name: Posted
  • Column example current value: 2020-12-11 02:00:00
  • Column example after change value: 2020-12-10 18:00:00
1 Answers

You can just change the time using interval arithmetic:

update my_posts
    set posted = posted - interval 8 hour;
Related