Reputation: 519
What is the best way to copy a date field to a datetime field using mysql?
I need to take the date from the date column and copy it over to the datetime field with a generic hour:min:00.000.
Ex: 2017-04-04 to 2017-04-04 11:05:57.000 (actual time does not matter)
Any ideas on the best approach for this?
Upvotes: 1
Views: 107
Reputation: 108796
Try this
CAST(date_column AS DATETIME)
But you really don't need to do anything special. When a DATE
field is evaluated in a DATETIME
or TIMESTAMP
context, the server coerces the data automatically.
Upvotes: 2