Skip to content Skip to sidebar Skip to footer

Sqlite Return Records Where Date Is More Than A Week Old

I am making a program for a book library and in the sqlite database there is a table for the books which includes the date that book was last taken out. I need a query to show ove

Solution 1:

Your datetime comparison is causing the issue here. It rather should be

AND takenOut < datetime('now', '-7 day')

See SQLite Date And Time Functions for more information

That should be a > comparison

AND takenOut > datetime('now', '-7 day')

You can as well try like below, if you are comparing with the date part only

WHEREDATE(takenOut) >=DATE('now', 'weekday 0', '-7 days')

Post a Comment for "Sqlite Return Records Where Date Is More Than A Week Old"