skip to Main Content

I want to change date only without the timestamp part. I’m trying to change from phpMyAdmin. So it doesn’t execute 3 parameters of DATEDIFF.

For e.g:

post_date
2020-12-16 23:20:48
2020-12-16 23:40:42

Add 4 days

post_date
2020-12-20 23:20:48
2020-12-20 23:40:42

OR Change date to current date (Today is 28th of December 2020)

post_date
2020-12-28 23:20:48
2020-12-28 23:40:42

2

Answers


  1. You could adjust it with an interval:

    UPDATE post
    SET    post_date = DATE_ADD(post_date, INTERVAL 4 DAY)
    
    Login or Signup to reply.
  2. If you want to translate the stored date to today’s date, you can do:

    update mytable 
    set post_date = addtime(current_date, time(post_date))
    

    Or using string operations:

    update mytable 
    set post_date = concat(current_date, ' ', time(post_date))
    

    The other question is just simple date arithmetics. You can add 4 days to a date by adding an interval, like:

    update mytable 
    set post_date = post_date + interval 4 day
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search