I am trying to 'normalize' some data from a column that has two date formats, one like "Mon dd, yyyy and another "YYYY-mm-dd". I would like to convert all of the first into the second format, and then change the column type to date.
I imagine it is something like this:
UPDATE table SET
`thedate` = DATE_FORMAT(`thedate`, '%Y-%m-%d')
WHERE `th开发者_C百科edate` LIKE '%,%'
but the DATE_FORMAT is the wrong function, I think.
Any ideas?
thanks.
I think I got it.
SELECT date_format( str_to_date( thedate, '%M %d, %Y' ) , '%Y-%m-%d' )
newdate, thedate
FROM donor
WHERE `thedate` LIKE '%,%'
精彩评论