Answer the question
In order to leave comments, you need to log in
How to compose SQLITE query with DateTime?
Hello. SQLITE database.
I have a table with a DateTime column in the format 2020-08-24 08:00:00. How to write a query to get data by date?
For example, today is 2020-08-24 09:03:40, I need to get a record whose date is less than 2020-08-24 08:00:00.
I'm building a query:
SELECT * FROM table WHERE (dateStart < date('2020-08-24 08:00:00')) ASC LIMIT 1 The
query works. But I get the value only if the day is yesterday, that is, the date is less than 2020-08-24. The time itself is not taken into account
in the query The problem is in constructing a query for a string whose date coincides with the current one. Let me explain with an example:
Today is 2020-08-24 09:03:40 I need to get data whose date is less than 2020-08-24 08:00:00. If I use the query above, then I DO NOT receive data with the date 2020-08-24, but they are in the table.
How to build a query with reference to time and date?
PS this one doesn't work either
SELECT * FROM table WHERE (dateStart <= date('2020-08-24 08:00:00'))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question