Reputation: 10354
I am new to mysql. I need to insert the string '2014-07-10 13:33:33' into the table column which has datetime datatype.
I gave like this,
SELECT STR_TO_DATE('2014-07-09 23:30:00', '%Y/%m/%d %h:%m:%s');
But i didn't not give the result. How to do this?
Upvotes: 7
Views: 19129
Reputation: 61401
SELECT STR_TO_DATE('2014-07-09 23:30:00', '%Y-%m-%d %H:%i:%s');
%Y
for year numeric, four digits
%m
for month numeric
%d
for Day of the month, numeric
%H
for 24 hours
%i
for minutes
%s
for seconds
Upvotes: 6
Reputation: 1269773
Minutes is %i
, not %m
and 24-hour format is %H
, not %h
:
SELECT STR_TO_DATE('2014-07-09 23:30:00', '%Y-%m-%d %H:%i:%s');
Upvotes: 20