Here is what I have:
SELECT * FROM allmessages WHERE timestamp <= strftime('%s', 'now')*1000 AND timestamp >= strftime('%s', 'now', '-365 days')*1000;
Some reservations:
Do your timestamps seem to be in milliseconds from an era? I multiply the internal SQLite timestamps by 1000 to reflect this.
Do you need dates between today and a year ago (2012)? If so, the above request will be fine; if you need dates from today to year (2014), flip the comparison operators.
I am using the internal SQLite rowid ; you can move this to other databases by replacing this for your own id column.
Here is a real demonstration of SQL Fiddle.
source share