The simplest query in the world isnt working in SQLite:
SELECT * FROM "events"
WHERE "date" >= datetime('2021-08-05T22:00:00') AND
"date" < datetime('2021-08-12T22:00:00');
The dates in the table as follows and I only receive last 2:
2021-08-12T16:00:00
2021-09-10T16:00:00
2021-10-12T16:00:00
2021-11-09T17:00:00
2021-12-09T17:00:00
2021-08-12T16:00:00
2021-09-10T16:00:00
2021-10-12T16:00:00
2021-11-09T17:00:00
2021-12-09T17:00:00
2021-08-12T16:00:00
2021-09-10T16:00:00
2021-10-12T16:00:00
2021-11-09T17:00:00
2021-12-09T17:00:00
2021-08-12T16:00:00
2021-09-10T16:00:00
2021-10-12T16:00:00
2021-11-09T17:00:00
2021-12-09T17:00:00
2021-08-12T16:00:00
2021-09-10T16:00:00
2021-10-12T16:00:00
2021-11-09T17:00:00
2021-12-09T17:00:00
2021-08-12T16:00:00
2021-09-10T16:00:00
2021-10-12T16:00:00
2021-11-09T17:00:00
2021-12-09T17:00:00
2021-08-11T16:00:00
2021-08-12 16:00:00
I inserted values by pasting simple text from notepad in SQLiteStudio v3.2.1
If you execute:
the result is:
Do you notice the missing
'T'?So, you are comparing strings (in SQLite dates are strings) and the comparison is alphabetical, but in the left side of the inequality you have a string with a
'T'and in the right side a string without a'T'.Either use the function
datetime()in both sides of the inequality:or, don't use it at all:
See the demo.