I have a field called date_expired I'm trying to run a query that will take the date_expired field and show records that will expire within 30 days from now.
Select *
From YourTable
Where Date_Expired >= GetDate()
And Date_Expired <= DateAdd(Day, 30, GetDate())
This should get you really close.
Please be aware that GetDate() includes date and time. If your date_expired column includes time information as well as date information, then you should be very careful about rows that expire in exactly 30 days.
-George
Microsoft SQL Server MVP My Blogs SQLCop twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.