I have "date" column in mysql saving the dates with this format
17-09-2014 (DD-MM-YYYY)
I need to sort them ascending, so I used this command:
SELECT * FROM table ORDER BY date ASC
But I found this result:
17-09-2014
18-09-2015
19-09-2014
It should be:
17-09-2014
19-09-2014
18-09-2015
It sorts the day only ASC not the full date
Ascending order means the smallest or first or earliest in the order will appear at the top of the list: For numbers or amounts, the sort is smallest to largest. Lower numbers or amounts will be at the top of the list. For letters/words, the sort is alphabetical from A to Z.
Click Home tab > arrow under Sort & Filter, and then click Sort Oldest to Newest, or Sort Newest to Oldest.
You can use the ASC and DESC keywords to specify ascending (smallest value first) or descending (largest value first) order. The default order is ascending.
Try this:
SELECT * FROM table ORDER BY STR_TO_DATE(date,'%d-%m-%Y') ASC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With