Last updated on April 26th, 2016 at 10:21 pm

Sort MYSQL data by date, If you have a field inside mysql for DATE and you need to sort the data accordingly in ascending or descending order you can use this UNIX_TIMESTAMP(FIELD NAME).
You can even update your existing SQL TYPE to DATE but it may sometimes results in loss of date if you have not followed the format properly.
Say for instance you have a FIELD with name DATE and the type you have given is VARCHAR, if you need to sort the data using the date it got updated, then all you have to do is use the UNIX_TIMESTAMP option inside mysql. Run the query with the UNIX_TIMESTAMP function and you will get it sorted.

For EXAMPLE

SELECT * FROM TABLENAME WHERE Website = 'mistonline.in' ORDER by UNIX_TIMESTAMP(Date) LIMIT 10, 20

Leave a Reply

Your email address will not be published. Required fields are marked *