Firebird: Query to get "Range of time" based on unit: days, months, years, etc

PHOTO EMBED

Sun Jul 14 2024 15:04:40 GMT+0000 (Coordinated Universal Time)

Saved by @marcopinero #sql

WITH RECURSIVE date_range AS (
    SELECT date'2019-01-03' dateval, 0 mes  /*start date, use cast(? as date) if you need a parameter */
    FROM rdb$database
    UNION ALL 
    SELECT DATEADD(MONTH,1,dateval), mes + 1
    FROM date_range
    WHERE mes < 12 /* end date */
)
SELECT *
FROM date_range;
content_copyCOPY