Dainius Vaičiulis
Dainius Vaičiulis

Reputation: 502

Sqlite order by strftime not working

The time format in my table is like this : 02:59:00 (hh:mm:ss).

Have been trying to make the query like this:

SQL = "select * from Events Where date = '"+tomorrowDate+"' 
       AND city = '"+mCity+"' 
             order by strftime('%H:%M:%S',start_time) ASC;";  

However the time order still seems random. What am I doing wrong?

Upvotes: 0

Views: 1154

Answers (1)

ivan.sim
ivan.sim

Reputation: 9288

Looking at the docs, strftime is used to convert datetime to the specified format. You should be able to accomplish the ordering with just:

order by time(start_time) asc;

or

order by datetime(start_time) asc; # if date is included

without needing to convert the datetime format.

Upvotes: 1

Related Questions