Siddharth
Siddharth

Reputation: 5219

STR_TO_DATE in MySql gives error

I am facing some problem with STR_TO_DATE in mysql. The following is returning NULL.

select str_to_date('2012-04-28 23:00:15', '%Y-%m-%d %h:%i:%s');

What is wrong here?

Upvotes: 0

Views: 254

Answers (2)

daremy
daremy

Reputation: 157

Can use also:

str_to_date('2012-04-28 23:00:15', '%Y-%m-%d %T')

Upvotes: 1

Wiseguy
Wiseguy

Reputation: 20883

You need capital %H, not a lowercase %h.

According to the docs,

%H Hour (00..23)
%h Hour (01..12)

Upvotes: 2

Related Questions