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
ParameterTypeRequiredDescription
start`DATETIMESTAMP`Yes
intervalINTERVALYesNon-zero step between consecutive elements
countBIGINTYesNumber of elements; non-positive values yield an empty array

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
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 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][]

Last update at: 2026/05/26 17:22:09