SEQUENCE()
All functions > DATE AND TIME > SEQUENCE()
Generates an inclusive array of dates or timestamps separated by an interval.
Signatures
Date sequence
Returns: Array of dates or timestamps in the sequence
SEQUENCE(start: DATE | TIMESTAMP, stop: DATE | TIMESTAMP, step: INTERVAL) → ARRAY<DATE> | ARRAY<TIMESTAMP> sql
| Parameter | Type | Required | Description |
|---|---|---|---|
start | `DATE | TIMESTAMP` | Yes |
stop | `DATE | TIMESTAMP` | Yes |
step | INTERVAL | Yes | Interval between elements (required) |
Signature notes:
- The INTERVAL step is required — there is no default for temporal types
- Month-based intervals respect calendar month boundaries
- Both start and stop are included when reachable by the given step
Notes
- Generates sequence from start to stop inclusive
- For integers: step defaults to 1; use a negative step for descending sequences
- For dates and timestamps: the INTERVAL step is required (no default)
- Month-based intervals (e.g.
1 month) respect calendar month boundaries - If start equals stop the result contains exactly one element
Aliases
RANGEGENERATE_SERIES
See also
Examples
Integer sequences
FeatureQL
SELECT
f1 := SEQUENCE(1, 5), -- Default step 1
f2 := SEQUENCE(5, 1, -1), -- Descending with negative step
f3 := SEQUENCE(3, 3) -- Single-point range
;Result
| f1 ARRAY | f2 ARRAY | f3 ARRAY |
|---|---|---|
| [1, 2, 3, 4, 5] | [5, 4, 3, 2, 1] | [3] |
Date sequences
FeatureQL
SELECT
f1 := SEQUENCE(DATE '2024-01-01', DATE '2024-01-05', INTERVAL_PARSE('1 day')), -- Day-by-day sequence
f2 := SEQUENCE(DATE '2024-01-31', DATE '2024-04-30', INTERVAL_PARSE('1 month')) -- Monthly steps respect calendar boundaries (leap year Feb)
;Result
| f1 ARRAY | f2 ARRAY |
|---|---|
| [2024-01-01, 2024-01-02, 2024-01-03, 2024-01-04, 2024-01-05] | [2024-01-31, 2024-02-29, 2024-03-29, 2024-04-29] |
Timestamp sequences
FeatureQL
SELECT
f1 := SEQUENCE(TIMESTAMP '2024-03-01 00:00:00', TIMESTAMP '2024-03-01 06:00:00', INTERVAL_PARSE('2 hours')) -- Two-hour steps within a single day
;Result
| f1 ARRAY |
|---|
| [2024-03-01, 2024-03-01T02:00:00, 2024-03-01T04:00:00, 2024-03-01T06:00:00] |