Help order the result by date in SQLite

Is there any way in SQLite for ORDER BY by date, and the result will be sorted by time, not alphabetically?

For instance:

SELECT * FROM details GROUP BY date;

John    |     Smith     |     April 01, 2011
John    |     Smith     |     April 03, 2011
John    |     Smith     |     April 04, 2011
John    |     Smith     |     March 25, 2011

The march should arrive before April.

I suppose the answer here is to store my dates as long timestamps, however I was not sure that this could be done using SQLite.

Thank!

+5
source share
5 answers

SQLite does not have a built-in type DATE(like some other database management systems), but it has a good addition to the date and time functions: http://www.sqlite.org/lang_datefunc.html

( "01 2011 ." ), ISO-8601 (, 2011-04-01).

, . 2011-03-25 2011-04-01 , .

, date() ( ).

+11
+3

You can do something like this

select * from sometable order by date (thestringDateColumn)

Hope this helps

0
source

Try the following:

SELECT * FROM details GROUP BY date ORDER BY date ASC;
-4
source

All Articles