I have a table with a string column (varchar(200)) that contain a date in different format. For example
may 24 1983 12:00AM
1981-01-13 00:00:00
1979-01-13 00:00:00:123
I want to convert this column in a date to extract year. How could i do? I have used STR_TO_DATE but don’t work well. I must use SUBSTRING for each different format?
MySQL version 5.0.95
There’s a trick for detecting a valid date on the man page. You can use it to determine whether a
STR_TO_DATEformat worked.Put one format for everyone you’re expecting. Test like crazy.
Good luck.
(Oh, and congrats for trying to cleanup a bad schema!)