Query with Epoch Timestamps

Query using epoch timestamps instead of timestamp literals.

Problem

You want to query data using an epoch time interval rather than using timestamp literals or timestamp_ns data types.

Solution

Use epoch values directly in your WHERE clause. QuestDB expects microseconds by default for timestamp columns:

Query with epoch microsecondsDemo this query
SELECT *
FROM trades
WHERE timestamp BETWEEN 1746552420000000 AND 1746811620000000;

Note: If you have epoch values in milliseconds, you need to multiply by 1000 to convert to microseconds.

Nanoseconds can be used when the timestamp column is of type timestamp_ns.

Related Documentation