A timestamp range is safest written half-open: >= start AND < next_start. That keeps the whole final day and excludes the first instant of the next period. BETWEEN, being closed on the right, stops at the month-end's midnight and loses that day's daytime.
SELECT id FROM sessions WHERE ended BETWEEN TIMESTAMP '2024-06-01' AND TIMESTAMP '2024-06-30' ORDER BY id;
SELECT id FROM sessions WHERE ended >= TIMESTAMP '2024-06-01' AND ended < TIMESTAMP '2024-07-01' ORDER BY id;
The June parking report drops every session that ended after midnight on the 30th — BETWEEN's closed upper bound cuts the last day short.
Write ranges as [start, next_start) with >= and <, generated one period at a time, so no day is ever half-counted.
ts >= DATE '2024-03-01' AND ts < DATE '2024-04-01'