>_QueryLocalCSV & JSON tools that run in your browser

How do I filter rows between two dates in SQL?

SELECT * FROM data
WHERE order_date BETWEEN '2025-01-10' AND '2025-01-20'
ORDER BY order_date;

Run this query on the demo dataset →

When dates are stored as text in YYYY-MM-DD format, plain string comparison sorts and compares them correctly because that format is lexicographically ordered the same as chronologically ordered. BETWEEN 'a' AND 'b' is inclusive on both ends, equivalent to order_date >= 'a' AND order_date <= 'b'.

A table named data with columns: order_id (integer), customer (text), country (text), category (text), quantity (integer), unit_price (real), order_date (text, YYYY-MM-DD).

Want to run it on your own file? Open it with Filter a CSV: your file becomes the table data, and you can paste this query with your own column names.

Related recipes