generate days from date range

后端 未结 29 2417
渐次进展
渐次进展 2020-11-21 05:19

I would like to run a query like

select ... as days where `date` is between \'2010-01-20\' and \'2010-01-24\'

And return data like:

29条回答
  •  执笔经年
    2020-11-21 06:09

    SQLite version of RedFilters top solution

    select d.Date
    from (
        select 
        date(julianday('2010-01-20') + (a.a + (10 * b.a) + (100 * c.a))) as Date
        from (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as a
        cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as b
        cross join (select 0 as a union all select 1 union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9) as c
    ) d
    where 
    d.Date between '2010-01-20' and '2010-01-24' 
    order by d.Date
    

提交回复
热议问题