Reputation: 33
Is there any way to retrieve SORTED resultset from mysql table where date is stored in unix way? I mean something like this "Select * from tableName order by DATE DESC", if its in Unix type it means it is stored as integer or bigint, so it doesnt really work that way I wrote here, any help?
Upvotes: 0
Views: 155
Reputation: 247680
If you want to order the data by date instead of the unix int/bigint then you can convert the unix time to a date using FROM_UNIXTIME
select *
from tableName
order by FROM_UNIXTIME(DATE) desc
Ordering by the unix value before the conversion should still work because it is an int value.
Upvotes: 1
Reputation: 34055
You can use FROM_UNIXTIME
.
SELECT ..
ORDER BY FROM_UNIXTIME(column)
Upvotes: 1