avikar96
avikar96

Reputation: 103

How to get events in the last 24 hours with SQLite?

I have a column with datetime entries, and I would like to get all the items from the last 24 hours. Right now I'm trying:

SELECT * FROM " + SQLHelp.LOG_TABLE + " WHERE " + SQLHelp.TIME_COLUMN + "> datetime('now','-1day')

where SQLHelp.LOG_TABLE and SQLHelp.TIME_COLUMN are the names of the table and column respectively.

Upvotes: 4

Views: 3626

Answers (1)

avikar96
avikar96

Reputation: 103

There must be a space between -1 and day; datetime('now','-1 day') works as expected.

Upvotes: 3

Related Questions