Search Shortcut cmd + k | ctrl + k

QuestDB's TICK interval syntax for time filters, e.g. WHERE ts IN '[2025-01]T09:30@America/New_York#workday;6h30m'

Maintainer(s): lstefano71

Compatibility Matrix

This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.

Platform 1.4.4 1.4.5 1.5.5 1.5.6 2.0.0
Linux AMD64
Linux ARM64
macOS AMD64
macOS ARM64
Windows AMD64
Windows ARM64
WebAssembly

Installing and Loading

INSTALL tick FROM community;
LOAD tick;

Example

-- plain TIMESTAMP values are read in the session TimeZone
SET TimeZone = 'UTC';

-- one row per minute of January 2025
CREATE TABLE trades AS
SELECT ts, random() AS price
FROM range(TIMESTAMP '2025-01-01', TIMESTAMP '2025-02-01', INTERVAL 1 MINUTE) t(ts);

-- NYSE trading hours on every workday of January (holidays aside)
SELECT count(*), min(ts), max(ts)
FROM trades
WHERE ts IN '[2025-01]T09:30@America/New_York#workday;6h30m';

-- the first hour of trading on the workdays of January 1st to 7th
SELECT count(*) FROM trades WHERE ts IN '2025-01-[01..07]T09:30@America/New_York#workday;1h';

-- the intervals a pattern expands to
SELECT * FROM tick_intervals('[2025-01]T09:30@America/New_York#workday;6h30m') LIMIT 3;

About tick

The tick extension implements QuestDB's TICK syntax (Temporal Interval Calendar Kit): one compact string describing many time windows, with date lists, bracket expansion, ISO weeks, $now/$today arithmetic including business days, time zones, day-of-week filters and durations:

SELECT * FROM trades WHERE ts IN '$today - 5bd..$today - 1bd';        -- the last five business days
SELECT * FROM trades WHERE ts IN '$now - 1h..$now';                   -- the last hour
SELECT * FROM logs   WHERE ts IN '2024-[01,04,07,10]-[01..07]T02:00#Sun;6h';  -- first Sunday of each quarter

x IN '<pattern>' becomes tick_in(x, '<pattern>') through a DuckDB 2.0 grammar extension that is activated automatically by LOAD tick (for statements parsed after the LOAD). The pattern is expanded once per query and the filter is pushed into scans: Parquet files and DuckDB tables skip row groups whose min/max cannot match, and every scanner receives the overall time range as plain comparisons. tick_intervals(pattern) lists the expanded intervals. Patterns follow the session TimeZone; see the repository README for the differences from QuestDB.

Added Functions

function_name function_type description comment examples
tick_in scalar NULL NULL  
tick_intervals table NULL NULL  

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

name description input_type scope aliases typed_value
active_grammar_extensions The grammar extensions used by the parser. VARCHAR[] LOCAL [] [shell, tick]
temp_directory Set the directory to which temporary files are written. VARCHAR GLOBAL [] post.db.tmp
tick_now Overrides the instant $now refers to in TICK patterns TIMESTAMP WITH TIME ZONE GLOBAL [] NULL