Answer the question
In order to leave comments, you need to log in
How to select a record from SQLite with the most appropriate time?
Hello.
The table has 2 columns with time one with unuxtime the other looks like ymd h:m:s
All records in the table with an interval of 3 hours.
2016-03-24 06:00:00
2016-03-24 09:00:00
2016-03-24 12:00:00
How do I select the most "recent" entry in time. for example, if now is 2016-03-24 10:25 then select the record with the time 2016-03-24 09:00:00. DB sqlite
I hope the question was formulated clearly
Answer the question
In order to leave comments, you need to log in
SELECT * FROM yourtable
WHERE
unuxtime_column <= strftime('%s', 'now', 'localtime')
ORDER BY unuxtime_column DESC LIMIT 1;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question