views:

162

answers:

0

I have a field in my database that stores the datetime that an item was added to the database. If I want to sort the items in reverse chronological order I would expect that doing ORDER by date_added DESC would do the trick. But this seems not to work. I also tried ORDER by UNIX_TIMESTAMP(date_added) but this still did not sort the results as I would expect. I also have an auto-increment field that I can use to sort items so I will use this, but I am curious as to why ORDER by datetime was not behaving as expected.

any ideas?

Query looks like:

SELECT file_name, date_added
FROM table WHERE DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date_added 
ORDER BY date_added DESC