How would I write a SQLite query to select all records from a specific month? My dates are stored as Unix timestamps.
PHP code is allowed in your solution if it's required. SQLite2-compatible queries only, please. :)
How would I write a SQLite query to select all records from a specific month? My dates are stored as Unix timestamps.
PHP code is allowed in your solution if it's required. SQLite2-compatible queries only, please. :)
If you want an efficient query then you should use BETWEEN:
SELECT *
FROM Table1
WHERE date BETWEEN $start AND $end
Where start
and end
are the unix timestamps for the start of the month and the end of the month. These can be calculated in PHP using mktime and sent as parameters.