Starting with : 2011-01-17 09:30:00
Let's say I want to edit just the date with 2011-01-28
What is the most efficient way to end up with: 2011-01-28 09:30:00
Thanks!
For everyone saying Date_Add... that would require me to subtract the dates, then add the days. Thats a possibility... but was looking to remove that first step, and just "replace" the date
If you really don't want to use date_add function, you can consider using this construction:
UPDATE table_name SET field_name = concat('2011-01-12 ', time(field_name))
Make sure to add a space after the date ('2011-01-12◯
').
To change it 5 days ahead:
UPDATE yourTableName
SET myDate1 = myDate1 + INTERVAL 5 DAY
WHERE myDate1 = dateIWantToChange
(you can use MONTH, YEAR, etc too)
Probably, DATE_ADD is a good idea. link text
Check Query
update yourtable set eventtime=replace(eventtime,substr(eventtime,1,10), '2013-07-17') WHERE `id`=4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With