You may want to use the STR_TO_DATE() function. It’s the inverse of the DATE_FORMAT() function.
STR_TO_DATE(str,format)
This is the inverse of the
DATE_FORMAT()function. It takes a stringstrand a format stringformat.STR_TO_DATE()returns aDATETIMEvalue if the format string contains both date and time parts, or aDATEorTIMEvalue if the string contains only date or time parts. If the date, time, or datetime value extracted fromstris illegal,STR_TO_DATE()returnsNULLand produces a warning.
Example:
SELECT STR_TO_DATE('15-Dec-09', '%d-%b-%y') AS date;
+------------+
| date |
+------------+
| 2009-12-15 |
+------------+
1 row in set (0.00 sec)