Skip to content
Advertisement

How can I update date of datetime field with mysql only?

I have a table like this

I want to update only the date but dont know where to start from. I mean in the datetime field date i want to update the date ‘2014-01-08’ to ‘2014-01-01’. How can i do that? I have tried this.

Here is the

Fiddle Structure

Advertisement

Answer

One option is to use this:

Fiddle: http://sqlfiddle.com/#!2/28d71/1

For better performance use the following query because index (if any) can be used by MySQL as DATE() is not on the left side of comparison operator:

Fiddle: http://sqlfiddle.com/#!2/7e7b2/1

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement