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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -