0

My time is sent to the database as a string e.g.

8:00 AM
9:00 AM
12:50 PM

I want to retrieve them from the database in the order of time. Researched another question and I realised it could be done in MySQL like so:

SELECT * 
FROM table_name 
ORDER BY STR_TO_DATE(timeField,'%h.%i%p');

Is there a way I can do it the same way in SQLite? Tried the codes above and logcat states there is no such function.

user3763216
  • 489
  • 2
  • 10
  • 29
  • 6
    My 2 cents: you'd better off store it as a timestamp instead of a varchar – dotvav Aug 04 '15 at 12:33
  • 3
    https://www.sqlite.org/lang_datefunc.html – CommonsWare Aug 04 '15 at 12:34
  • Is there any reason to store a time in string format? See https://www.sqlite.org/datatype3.html and to store the time @CommonsWare link. – joninx Aug 04 '15 at 12:39
  • Visit this links in stackoverflow. it may help you to solve your problem. [Android SQLite Inserting and Ordering by time](http://stackoverflow.com/questions/5709989/android-sqlite-inserting-and-ordering-by-time) [How do i order my SQLITE database in descending order, for an android app?](http://stackoverflow.com/questions/8948435/how-do-i-order-my-sqlite-database-in-descending-order-for-an-android-app) [android sqlite how to order by time](http://stackoverflow.com/questions/12974150/android-sqlite-how-to-order-by-time) – Amit Vaghela Aug 04 '15 at 12:41

0 Answers0