Mysql: Editing only the date in datetime

Recently I was looking for a way to do data testing in my project which involves data with date time. Since it was querying for the current day and my data was older, I wanted to change the date part of the datetime column. Anyways, here is how I did it:

UPDATE tablename SET fieldname = concat('2015-04-14 ', time(fieldname)) WHERE DATE(fieldname) = '2015-04-10'

‘2015-04-14’ is the new date we want to apply and ‘2015-04-10’ is the old date that we want to look for.

Advertisements