Hi PRA,
PRA says:
print DATEADD(
year
, 1, @
date
)
You need to pass @num instead of 1.
Refer below sample query.
SQL
declare @num int, @date date, @res int
set @date = '2017-04-14'
set @res = CONVERT(VARCHAR,CONVERT(INT,DATEDIFF(DD,@date,GETDATE())/365.25))
set @num = 0
while(@num <= @res)
begin
if(@num = 0)
BEGIN
print @date
END
else if(@num > 0)
BEGIN
print DATEADD(year, @num, @date)
END
set @num = @num + 1
end
Output
2017-04-14
2018-04-14
2019-04-14