mysql - Change varchar m/d/yy to yyyy-mm-dd -


i have varchar(9) column data in form m/d/yy. want convert yyyy-mm-dd. can select values , view changes using query,

select str_to_date(date_new,'%m/%d/%y') date   july 

my problem how update values in column. tried using query, messes dates.

update july    set date_new = str_to_date(date_new, '%d-%m-%y' ); 

any gladly accepted!

thank in advance. :)

you close. can use date_format() convert desired string representation.

update july    set date_new = date_format(str_to_date(date_new,'%m/%d/%y'), '%y-%m-%d'); 

note: you'd need change column varchar(9) varchar(10) fit reformatted values.

alter table july modify date_new varchar(10); 

here sqlfiddle.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -