now
Return the current server DateTime — the anchor for relative time filters.
Signature
now(): DateTimeReturns
DateTime
What it does
Returns the current server DateTime at query execution time. Used as the anchor point for relative time range filters and as a default value for inserted rows.
now() is called once per query (not once per row), making it safe and efficient for WHERE clause filtering. Combining now() with INTERVAL arithmetic covers almost all relative time window queries: last N hours, rolling 30 days, since start of today. It always returns server time — if your ClickHouse cluster is set to UTC, now() returns UTC.
Notes
- now() is evaluated once per query, not per row — safe for partition pruning.
- now64() provides sub-second precision (returns DateTime64).
- today() returns just the current Date (no time); yesterday() returns yesterday's Date.
- For reproducible tests, replace now() with a fixed timestamp.
Example SQL
now in ClickHouse SQL
TypeScript with hypequery
Use now in a typed TypeScript query
hypequery gives you a type-safe query builder for ClickHouse. The generated schema maps your ClickHouse columns to TypeScript types, and raw SQL expressions let you incorporate functions like now when you need them inside a builder query.
Common questions
What developers search for with now
ClickHouse last 7 days filter
WHERE created_at >= now() - INTERVAL 7 DAY is the idiomatic ClickHouse pattern. In hypequery, pass a JavaScript Date calculated from Date.now().
ClickHouse current timestamp
now() gives you the server DateTime. now64() gives microsecond precision. today() gives just the date.
FAQ
Frequently asked questions about now
Is now() evaluated per row or per query?
Per query. It is called once when the query starts executing, so all rows in the same query see the same timestamp.
How do I get millisecond precision?
Use now64() which returns DateTime64(3) — milliseconds. Or now64(6) for microseconds.
Next step
Use now in a type-safe TypeScript query
hypequery generates TypeScript types from your ClickHouse schema. Use now alongside the builder, and reach for raw SQL expressions when the function is not exposed as a dedicated helper.