DATE_SEQUENCE()
All functions > DATE AND TIME > DATE_SEQUENCE()
Returns an array of timestamps: count values beginning at start, each separated by interval.
Signatures
Returns: Inclusive sequence from start with step interval
DATE_SEQUENCE(start: DATE | TIMESTAMP, interval: INTERVAL, count: BIGINT) → ARRAY<TIMESTAMP> sql
| Parameter | Type | Required | Description |
|---|---|---|---|
start | `DATE | TIMESTAMP` | Yes |
interval | INTERVAL | Yes | Non-zero step between consecutive elements |
count | BIGINT | Yes | Number of elements; non-positive values yield an empty array |
Notes
- Element type is always TIMESTAMP so DATE starts align at midnight in the result
countmust be an integral type; whencountis NULL the result is NULL- A zero-length sequence is returned when
count≤ 0 (not an error) - If the step interval is zero, the result is an empty array—use a non-zero step for predictable results
Examples
FeatureQL
SELECT
f1 := DATE_SEQUENCE(TIMESTAMP '2024-01-01 00:00:00', INTERVAL '1 day', 5), -- Five consecutive days
f2 := DATE_SEQUENCE(TIMESTAMP '2024-01-01 10:00:00', INTERVAL '3 hours', 3), -- Hour-sized steps
f3 := DATE_SEQUENCE(DATE '2024-01-01', INTERVAL '1 day', 3), -- DATE start promoted to TIMESTAMP elements
f4 := DATE_SEQUENCE(TIMESTAMP '2024-01-01 00:00:00', INTERVAL '1 day', 0) -- Non-positive count is empty
;Result
| f1 ARRAY | f2 ARRAY | f3 ARRAY | f4 ARRAY |
|---|---|---|---|
| [2024-01-01, 2024-01-02, 2024-01-03, 2024-01-04, 2024-01-05] | [2024-01-01T10:00:00, 2024-01-01T13:00:00, 2024-01-01T16:00:00] | [2024-01-01, 2024-01-02, 2024-01-03] | [] |
On this page