i have come across a mysql database which has dates entered in a varchar column in various random formats e.g below
01/01/1977
05-05-1980
58 ( age to be converted to date )
1.2.1990
02/02/87
01-Mar-73
How do i convert this into one unified format – dd/mm/yyyy
Also when i try to convert varchar into date column with this data
SELECT
CAST(date_column AS DATE)
FROM
table_name
i don’t know why is it giving me all nulls for date value as a result
I would use regex to check for the format, then use the appropriate specifiers in STR_TO_DATE to get a standard format. Perhaps someone can help on the regex?
Pseudo-code:
Specifiers: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format