Sqlite delete rows older than

1.5k views Asked by At

I have records in database:

record B with property `Checked` set to be current date in UTC.
record A with property `Checked` set to be current date in UTC - 48 hours.

Then I want to create query to delete rows with property Checked older than 24 hours.

In my case only A should be deleted. Checked is stored as bigint in database.

db.Execute("DELETE FROM User WHERE Checked <= strftime('%s', datetime('now', '-1 day'))"); // A and B are not deleted
db.Execute("DELETE FROM User WHERE Checked <= datetime('now', '-1 day')"); // A and B are deleted
db.Execute("DELETE FROM User WHERE Date(checked) <= datetime('now', '-1 day')"); // A and B are not deleted
db.Execute("DELETE FROM User WHERE datetime(checked) <= datetime('now', '-1 day')"); // A and B are not deleted

Do you have any ideas what can be wrong there?

1

There are 1 answers

0
dafie On

I finally found a solution:

datetime(Checked/10000000 - 62135596800, 'unixepoch') <= datetime('now', '-1 day')