I have an sqlite table as follow:
I have to select the rows where 'start'< now time in order to have just the ongoing program; logically as:
if time now is 10:05 then the result should be:
How I can formulate the right select statement?
Thank u in advance for any help.
You can use the function strftime()
to get the current time in the format HH:MM
so that you can compare it to the column start
:
SELECT *
FROM tablename
WHERE start < strftime('%H:%M', 'now');
If you want only the last row for each dpt
:
SELECT *
FROM tablename
WHERE start < strftime('%H:%M', 'now')
GROUP BY dpt
HAVING MAX(start);