Get next NDays Birthdays of Employee - SQL SERVER
Declare @Days as Int
SET @Days = 15
Declare @ToDate as Date
Select @ToDate = DATEADD(d,@Days ,getDate())
Select * from
(
Select ID, EmployeeName, DateOfBirth, Cast(Format(DateOfBirth,'MM/dd/') + Convert(Varchar,year(getdate())) as Date) As NDOB From pr.mastEmployee
) AllData
Where NDOB >= getDate() and NDOB <= @ToDate
SET @Days = 15
Declare @ToDate as Date
Select @ToDate = DATEADD(d,@Days ,getDate())
Select * from
(
Select ID, EmployeeName, DateOfBirth, Cast(Format(DateOfBirth,'MM/dd/') + Convert(Varchar,year(getdate())) as Date) As NDOB From pr.mastEmployee
) AllData
Where NDOB >= getDate() and NDOB <= @ToDate
Comments
Post a Comment