Date ranges: month to date, year to date
For a period, compare the date with its first day and the day after its last:
SELECT COUNT(*)
FROM orders
WHERE order_date >= '2026-10-01' AND order_date < '2026-11-01'That's every order in October 2026. "Less than the first of next month" means you never have to know whether a month has 30 or 31 days, and it still works for timestamps (a time on 31 October is before 1 November).
Brightwell's data runs up to 31/10/2026, so treat that as "today". Month to date is then 01/10/2026 to 31/10/2026, and year to date is 01/01/2026 to 31/10/2026.
Other databases: dates written as
'2026-10-01'work in DuckDB, PostgreSQL, MySQL and SQL Server. BigQuery wantsDATE '2026-10-01', which DuckDB and PostgreSQL also accept.