Half-open ranges, start inclusive and next start exclusive, are correct at any precision on every engine, and the bare column can use its index. BETWEEN is only safe when the values carry no time part; on timestamps it is usually a quiet bug.
Where they differ
A day's data is occurred_at >= '2026-03-01' AND occurred_at < '2026-03-02'. The half-open upper bound is exact at any precision. BETWEEN '2026-03-01' AND '2026-03-01' matches only midnight, and BETWEEN … AND '2026-03-01 23:59:59' still loses 23:59:59.5 on columns with fractional seconds.
How each engine writes it
SQL Server
SELECT * FROM events WHERE occurred_at >= '2026-03-01' AND occurred_at < '2026-03-02';
datetime2 stores up to 100 ns, so a 23:59:59 upper bound misses 23:59:59.003. With the old datetime type, '23:59:59.999' rounds up to the next midnight.
PostgreSQL
SELECT * FROM events WHERE occurred_at >= TIMESTAMP '2026-03-01' AND occurred_at < TIMESTAMP '2026-03-02';
For timestamptz columns the bounds are read in the session time zone; use TIMESTAMPTZ '2026-03-01 00:00+00' to pin the zone.
MySQL
SELECT * FROM events WHERE occurred_at >= '2026-03-01' AND occurred_at < '2026-03-02';
A date literal compared with DATETIME means midnight. Plain DATETIME stores whole seconds, but DATETIME(3) or (6) columns make a 23:59:59 upper bound lossy.
SQLite
SELECT * FROM events WHERE occurred_at >= '2026-03-01' AND occurred_at < '2026-03-02';
ISO-8601 text sorts chronologically, so string comparison works as long as every stored value uses the same layout.
Oracle
SELECT * FROM events WHERE occurred_at >= DATE '2026-03-01' AND occurred_at < DATE '2026-03-02';
Oracle DATE has a time part, so occurred_at = DATE '2026-03-01' matches only rows stamped exactly at midnight.
Questions that come up
Why is BETWEEN wrong for timestamps?
BETWEEN is inclusive at both ends, so you have to name the last instant of the day, and that instant depends on the column's precision: 23:59:59 for whole seconds, 23:59:59.999999 for microseconds. Anything after your bound and before midnight is lost. < next midnight needs no such guess.
Do string comparisons work on timestamps in SQLite?
Yes, if every stored value uses the same ISO-8601 layout ('YYYY-MM-DD HH:MM:SS'), because then text order equals time order. Mixing layouts (a 'T' separator in some rows, a zone suffix in others) misorders silently, so normalize on write.
What about time zones in the bounds?
PostgreSQL reads zone-less literals in the session zone when comparing with timestamptz; MySQL converts TIMESTAMP values using the connection's time_zone; SQL Server datetime2 and Oracle DATE carry no zone at all. Compute the bounds in one explicit zone in the application and pass them as parameters.