Filter rows by a date range
Use a start date and "before the next day" so the whole last day is included.
SQL · Filter rows by a date rangeBeginner
-- all orders placed in October 2026
SELECT id, total, created_at
FROM orders
WHERE created_at >= '2026-10-01'
AND created_at < '2026-11-01';
-- the last 7 days
SELECT * FROM orders WHERE created_at >= NOW() - INTERVAL 7 DAY;datebetweenwhere