Hello.
How do I use SQL to order results by oldest first? I am using unix timestamps.
Thanks.
Hello.
How do I use SQL to order results by oldest first? I am using unix timestamps.
Thanks.
Unix time, or POSIX time, is a system for describing points in time, defined as the number of seconds elapsed since midnight proleptic Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds
The ORDER BY clause can use ASC or DESC, if you sepcify none it will default to use ASC:
Most recent time stamps first:
SELECT * FROM tableName ORDER BY columnName DESC
Less recent time stamps first:
SELECT * FROM tableName ORDER BY columnName ASC
What's the problem you're having using ORDER BY 'unix-time-stamp-field' ASC;
?
EDIT: jemfinch
is right, it is ASC
.
The oldest UNIX timestamp is the one that's smallest, so you want to ORDER BY my_timestamp_column ASC
.
I have no idea why both the answers so far have said to order by the column DESC
.