sql - Converting MySQL string date to Y-m-d H:i:s -
i'm trying convert mysql string date y-m-d h:i:s
format. using sql @ moment, returns null value. doing wrong?
select date_format(str_to_date(week_ending,'%l %d %f %y'),'%y-%m-%d %h:%i:%s') week_ending worksheets
edit
week_ending in format: friday 08 may 2015
thanks in advance.
the correct format str_to_date
should be
mysql> select str_to_date('friday 08 may 2015','%w %d %m %y'); +-------------------------------------------------+ | str_to_date('friday 08 may 2015','%w %d %m %y') | +-------------------------------------------------+ | 2015-05-08 | +-------------------------------------------------+ 1 row in set (0.00 sec)
the format using return null
mysql> select str_to_date('friday 08 may 2015','%l %d %f %y'); +-------------------------------------------------+ | str_to_date('friday 08 may 2015','%l %d %f %y') | +-------------------------------------------------+ | null | +-------------------------------------------------+ 1 row in set, 1 warning (0.00 sec)
here list of formatting specifier https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format
Comments
Post a Comment