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, count: BIGINT, interval: INTERVAL) → ARRAY<TIMESTAMP>
sql
ParameterTypeRequiredDescription
start`DATETIMESTAMP`Yes
countBIGINTYesNumber of elements; non-positive values yield an empty array
intervalINTERVALYesNon-zero step between consecutive elements

Notes

  • Element type is always TIMESTAMP so DATE starts align at midnight in the result
  • count must be an integral type; when count is 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
RETURN
    -- Five consecutive days
    f1 := DATE_SEQUENCE(TIMESTAMP '2024-01-01 00:00:00', 5, INTERVAL '1 day'),
    -- Hour-sized steps
    f2 := DATE_SEQUENCE(TIMESTAMP '2024-01-01 10:00:00', 3, INTERVAL '3 hours'),
    -- DATE start promoted to TIMESTAMP elements
    f3 := DATE_SEQUENCE(DATE '2024-01-01', 3, INTERVAL '1 day'),
    -- Non-positive count is empty
    f4 := DATE_SEQUENCE(TIMESTAMP '2024-01-01 00:00:00', 0, INTERVAL '1 day')
;
Result
f1 ARRAYf2 ARRAYf3 ARRAYf4 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][]