Try this, hope this will be easy and simple way
--Try option 1
declare @days as int
set @days = 4
declare @dts as datetime
set @dts = GETDATE()
select name, birth_date
from <table name>
where (
CASE WHEN MONTH(birth_date) < MONTH(@dts) THEN (YEAR(@dts) + 1 ) * 10000
ELSE (YEAR(@dts) + 0 ) * 10000
END
) + MONTH(birth_date)*100 + DAY(birth_date) between convert(int,CONVERT(varchar(8), @dts, 112)) and
convert(int,CONVERT(varchar(8), dateadd(d,@days,@dts), 112))
--Or Try option 2 by creating Function which returns Birthdate as per current running year
-- =============================================
-- Author:VINAY M JADIA
-- Create date: 2012-12-31
-- Description:Function will change the year of given month with replacing date
-- =============================================
ALTER FUNCTION [dbo].[ufnChangeYear]
(
-- Add the parameters for the function here
@changingDate datetime,
@withDate datetime
)
RETURNS datetime
AS
BEGIN
-- Declare the return variable here
DECLARE @newDate datetime
SELECT @newDate = CONVERT(varchar(4),(
CASE WHEN MONTH(@changingDate) < MONTH(@withDate) THEN
YEAR(@withDate) + 1
ELSE YEAR(@withDate)
END
)
)+ '/' + RIGHT(CONVERT(VARCHAR(8), @changingDate, 11),5)
RETURN @newDate
END
----Query to fetch result using the newly created function
declare @days int
set @days = 365
declare @dtf datetime, @dtt datetime
set @dtf = CONVERT(datetime, CONVERT(varchar(10), GETDATE(), 111))
set @dtt = DATEADD(D, @days, @dtf)
select name, birth_date
from <tablename>
where dbo.ufnChangeYear(birth_date,getdate()) between @dtf and @dtt
--Hope this will work for n no of days even year, month changing