Suppose you write a query to sort a table by date field.
SELECT aDate FROM aTable ORDER BY aDate
The above query should sort aDate column in ascending order. But it doesnt work the way it should.
To sort date field in MySQL use following query:
SELECT DATE_FORMAT(aDate, '%d-%M-%Y') AS aDate, aDate AS sDate FROM aTable ORDER BY sDate
Hey Kunal.nice stuff.thanx.
U cud hav included more things here, than just one line.Neways good to know abt this.
If you know any other way to do it then please write
thx
But if the date filed was of the type ‘datetime’, the first query works as expected.
@tagnu : Correct
Any way to make it desc? cause it doesn’t work by putting “DESC” afterwards.
Thanks!
Nevermind, I’m using FROM_UNIXTIME now, thx