Android Question Is it better in SQL to store date separate from time?

edm68

Member
Licensed User
Longtime User
I've searched the forum and can't find an answer or example.
Not sure how to sort thru SQL data by time and not date?
If I write date/time to sql as long(ticks) I can't figure out how to sort by time.
Would it be better to store time in own field as string?
Thanks.
 

Roycefer

Well-Known Member
Licensed User
Longtime User
This might be of use to you: https://www.sqlite.org/lang_datefunc.html

Going by that page, if you store your date/time as ticks (a B4A Long) in a column called "timestamp" in a table called "thistable", you can get them sorted by time of day (earliest to latest):
B4X:
SELECT * FROM thistable ORDER BY TIME(timestamp) ASC;

Beware, this is untested.
 
Upvote 0
Top