add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create function dates (
@date date,
@period int,
@num int
)
returns table
as return
with dates as (
select @date as start_date,
dateadd(day, @period, @date) as additional_date,
@period as additional_days, 1 as n
union all
select start_date,
dateadd(day, @period, additional_date),
additional_days + @period, n + 1
from dates
where n < @num
)
select start_date, additional_date, additional_days
from dates
select *
from dates('2010-01-01', 30, 2)
start_date additional_date additional_days
2010-01-01 2010-01-31 30
2010-01-01 2010-03-02 60