pythonsqlsqlite

How do I sort date by newest first?


My SQLite database has a column called date which is DATETIME. I have used :

cur.execute("SELECT * FROM Posts ORDER BY date(date) DESC")

It orders oldest first but I want it the other way around.


Solution

  • I'll suggest you to try the inverse:

    cur.execute("SELECT * FROM Posts ORDER BY date ASC")
    

    and see if it works.

    Hope this helps!