Ivan
Ivan

Reputation: 15912

Why this MySQL date conversion returns NULL?

Trying to convert a date format into a MySQL date:

SELECT STR_TO_DATE('8/3/2011 13:30','%m/%d/%Y %h:%i');

but it returns NULL. Note that this similar query works:

SELECT STR_TO_DATE('8/3/2011 13:30','%m/%d/%Y');

Upvotes: 3

Views: 2851

Answers (1)

cHao
cHao

Reputation: 86506

%h expects a number from 01 to 12. 13 is invalid.

Try %H or %k instead. They're for 24-hour times.

Upvotes: 6

Related Questions