@events = Event.all(:order => "date DESC")
to order my events by date, a datetime column.
Is it possible to order them not by date, but only by hour? (I’m suing sqlite3 database)
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For SQLite,
Use that with care, because it ignores the date. (And see “Moments later” below.)
Only one of the dates is on Jan 2.
Moments later . . .
I realized you wanted to sort by hour, not by time. That questionable requirement takes a different expression, and sorts differently.
The last two rows are sorted correctly by hour, incorrectly by time.
Still later . . .
The OP deploys on Heroku, which doesn’t support SQLite. To sort by hour descending, the OP probably needs something like
And stop using one platform for development and a different platform for deployment.