Sunday, 15 March 2015

mysql - Sort Date with date which is in varchar getting issue in converting to date time with MM/DD/YYY -



mysql - Sort Date with date which is in varchar getting issue in converting to date time with MM/DD/YYY -

there issue datetime conversion "xl_date" have date mm/dd/yyyy

example query:-

select orders.*, customer.id userid, customer.login, convert(datetime, orders.xl_date, 101) ddates orders left bring together client on orders.userid = customers.id 1 order ddates desc limit 0, 30

you need utilize str_to_date function. illustration -

select str_to_date(orders.xl_date, '%m/%d/%y') as ddates orders

your query -

select orders.*, customer.id userid, customer.login, str_to_date(orders.xl_date, '%m/%d/%y')as ddates orders left bring together client on orders.userid = customers.id 1 order ddates desc limit 0, 30

mysql sql

No comments:

Post a Comment