I’ve been struggling with a SQL query and can’t find a answer anywhere, although I’ve come kinda close. I need to pull a range of users by hire date BUT just the month and day. For example I want to pull all users who had a hire date in the next 30 days regardless of hire year. So if I was hired July 28, 1992 and I ran this query my name would be included because July 28th is within the next 30 days. I have a view that is on the path to what I want:
SELECT *
FROM dbo.Users
WHERE DATEPART(m, dbo.Users.DateHired) = DATEPART(m, DATEADD(m, 1, GETDATE()))
This gets me everyone in the next month but I need to include the day in there somehow. Any ideas? I’m trying to figure out a “between” statement but can’t figure it out where it can span the month.
-Allan