Guide

How to filter a CSV by date range

Orders from last month, transactions between two dates, sign-ups in the past 30 days. Synth loads your CSV into a SQLite database in your browser, so a date filter is one query, and you can download the matching rows as a new CSV. Nothing is installed, and the file never leaves your computer.

The example file

Say you drop an orders.csv like this into Synth. It becomes a table called orders:

order_id | order_date       | total
1        | 2026-01-28       | 40.00
2        | 2026-02-03       | 15.50
3        | 2026-02-17       | 99.90
4        | 2026-02-28 18:45 | 12.00
5        | 2026-03-02       | 22.00
6        | 2026-03-30       | 61.25

Synth keeps every value exactly as it appears in the file, as text. Dates written as YYYY-MM-DD still sort and compare correctly as text, which is why the queries below work. If your dates look like 2/3/2026, skip to dates like 2/3/2026.

Rows between two dates

SELECT order_id, order_date, total
FROM orders
WHERE order_date >= '2026-02-01'
  AND order_date <  '2026-03-01';
order_id | order_date       | total
2        | 2026-02-03       | 15.50
3        | 2026-02-17       | 99.90
4        | 2026-02-28 18:45 | 12.00

Use less than the day after the range rather than BETWEEN. With WHERE order_date BETWEEN '2026-02-01' AND '2026-02-28', order 4 is left out, because 2026-02-28 18:45 comes after 2026-02-28.

Totals by month

strftime('%Y-%m', order_date) turns each date into its month, so you can group by it:

SELECT strftime('%Y-%m', order_date) AS month,
       COUNT(*) AS orders,
       ROUND(SUM(total), 2) AS revenue
FROM orders
GROUP BY month
ORDER BY month;
month   | orders | revenue
2026-01 | 1      | 40.0
2026-02 | 3      | 127.4
2026-03 | 2      | 83.25

The last 30 days

date('now', '-30 days') is the date 30 days before today, so this filter keeps moving as time passes:

SELECT order_id, order_date
FROM orders
WHERE order_date >= date('now', '-30 days');

Swap in '-7 days', '-3 months' or '-1 year' for other windows.

Dates like 2/3/2026

Many exports write dates as month/day/year. As text, 2/3/2026 sorts after 2/28/2026, so a filter like BETWEEN '2/1/2026' AND '2/28/2026' quietly misses February 3rd. Convert each date to YYYY-MM-DD first, then filter on the converted column:

WITH clean AS (
  SELECT *,
         substr(order_date, -4) || '-' ||
         printf('%02d', substr(order_date, 1, instr(order_date, '/') - 1)) || '-' ||
         printf('%02d', substr(order_date, instr(order_date, '/') + 1,
                               length(order_date) - instr(order_date, '/') - 5)) AS iso_date
  FROM orders
)
SELECT order_id, order_date, iso_date, total
FROM clean
WHERE iso_date >= '2026-02-01'
  AND iso_date <  '2026-03-01';
order_id | order_date | iso_date   | total
2        | 2/3/2026   | 2026-02-03 | 15.50
3        | 2/17/2026  | 2026-02-17 | 99.90
4        | 2/28/2026  | 2026-02-28 | 12.00

This handles dates with or without leading zeros, like 2/3/2026 and 02/03/2026. Once iso_date exists, the month and last-30-days queries above work on it too.

Save the filtered rows

Click Download CSV above the results to save them as a new file. Your original file is not changed.

Don't want to write SQL?

Sign in and ask the AI assistant something like "orders from February 2026." It writes the query from your column names, never your data.

Frequently asked questions

How do I filter a CSV by date range?

Drop the CSV into Synth and run SELECT * FROM table WHERE date_column >= '2026-02-01' AND date_column < '2026-03-01'. This works when dates are written as YYYY-MM-DD.

Why does my date filter miss rows?

Synth keeps dates exactly as they appear in the file, as text. Dates like 2/3/2026 don't sort in date order as text, so convert them to YYYY-MM-DD first. The guide has a copy-paste query for that.

Why is the last day of my range missing?

If the column includes a time, 2026-02-28 18:45 comes after 2026-02-28, so BETWEEN leaves it out. Use less than the day after the range instead.

How do I group rows by month?

Use strftime('%Y-%m', date_column) in the SELECT and GROUP BY it. That works on YYYY-MM-DD dates.

Does filtering change my file?

No. A query only creates a result. You can download that result with Download CSV, and the original file is never modified or uploaded.

How big a CSV can I use?

Up to 100,000 rows on the free plan, and up to 500,000 rows with Premium.

Filter your own CSV by date

No sign-in required to start.

Open Synth