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.
with activities (activityId, nextDate, frequency) as (
values (1, date '2024-03-01', 2)
),
activities_this_year (activityId, firstDate, number, nextDate, frequency) as (
select activityId, nextDate as firstDate, 1, nextDate, frequency from activities
union all
select
activityId,
firstDate,
number + 1,
nextDate + frequency month,
frequency
from activities_this_year
where nextDate + frequency month < this_year(current date) + 1 year
)
select activityId, nextDate from activities_this_year order by activityId, nextDate

ACTIVITYID NEXTDATE
1 2024-03-01
1 2024-05-01
1 2024-07-01
1 2024-09-01
1 2024-11-01