php - How to use order by in date using mysql query -
i using mysql database.but when sort date not sort.
select * `client` order `nextdate` asc
this query want data sort date in ascending order client table , nextdate
field type varchar. please how can sort date in ascending order.and want date formate 24/12/2016(d/m/y).
when use query sort first day not month this
01/08/2016 07/10/2016 21/08/2016
but want sort this
01/08/2016 07/08/2016 21/10/2016 25/12/2016
so please me how can do.in advance thax,
this long comment.
presumably, not storing date date. instead storing string. should use built-in mysql data types -- there for. if have to store date string, use yyyy-mm-dd
format. sorts correctly.
you can fix str_to_date()
:
order str_to_date(`nextdate`, '%d/%m/%y') asc
Comments
Post a Comment