I have date in this format 5 Mar 1985 0:00
stored in table as VARCHAR
.
I want to convert it into Datetime
, I am using the STR_TO_DATE()
as follows:
SELECT STR_TO_DATE(birth_date, '%d %m %Y %h:%i') FROM student WHERE pk = 29
But it returns NULL
.
Try this format - '%e %b %Y %k:%i'
, for example -
SELECT STR_TO_DATE('5 Mar 1985 2:33', '%e %b %Y %k:%i') dt;
+---------------------+
| dt |
+---------------------+
| 1985-03-05 02:33:00 |
+---------------------+