How to convert varchar date to datetime in MySQL -


how can convert following date format datetime format in mysql? right stored varchar. should use python script, or there inbuilt mysql function complete it?

    27 07 (2009), 10:38 pm, 

like this

select str_to_date('27 07 (2009), 10:38 pm', '%d %m (%y), %l:%i %p'); 

here specifiers: https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format

if original text contains trailing comma, match in pattern

select str_to_date('27 07 (2009), 10:38 pm,', '%d %m (%y), %l:%i %p,'); 

if want update column, can run update statement like:

update mytable  set dateat = str_to_date(dateat, '%d %m (%y), %l:%i %p,') 

and don't forget alter field varchar datetime


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -