Reputation: 19
I have a problem with the use of the STR_TO_DATE function.
My date has the following format
24.04.2012 11:24:50:360
I want to write it in my MySQL Column, where the format is
2012-04-24 11:24:50
To check if my statement is correct, I'm testing it with
SELECT STR_TO_DATE('24.04.2012 11:24:50:360', '%Y-%m-%d %H:%i:%s')
Everytime I run this, it returns NULL. I have no idea how I have to correct the query.
Upvotes: 1
Views: 102
Reputation: 49049
Try with this:
SELECT STR_TO_DATE('24.04.2012 11:24:50:360', '%d.%m.%Y %H:%i:%s')
(the format in your statement is not correct, you need to swap the year month and day, and you need to use . as a separator)
Upvotes: 4