-1

Given the table Use, defined as

CREATE TABLE Use(date TEXT NOT NULL, id TEXT PRIMARY KEY);

I want to make a query to find "All uses before today", however SQLite is not behaving as I expect and return the wrong value.

I tried to query using my table as such:

SELECT * FROM Use WHERE date <= datetime('now')
LeoColman
  • 6,950
  • 7
  • 34
  • 63

1 Answers1

0

The problem here is that date might not be in the same format that datetime returns.

You need first to convert the date to use the same format, by using the datetime function on it as well, and then you can compare both correctly:

SELECT * FROM Use where datetime(date) <= datetime('now')
LeoColman
  • 6,950
  • 7
  • 34
  • 63