Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
This is the question I am trying to answer (In Stat with 90 days remaining to OOS.) Which basically means I am trying to return any statute dates that run out with in 90 days. The date for the statute date is saved as 2001-04-10 00:00:00.000 and I am trying to go 90 days from today. aai.StatuteDate < DATEADD (day, 90, GETDATE()) <---This is what I used but didn't return what I wanted. I did also convert the statutedate to mm/dd/yyyy. Any help would be great.
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2012-05-07 : 15:16:36
If you are on SQL 2008, you can use this:
aai.StatuteDate < DATEADD (day, 90, CAST(GETDATE() AS DATE))
On SQL 2008 and earlier versions this should work:
Thank you very much. I knew I was missing something but couldn't put my finger on it.
FightingTiger
Starting Member
23 Posts
Posted - 2012-05-07 : 15:54:18
Another question just to make sure I am seeing this right. IF I were to change the < before the DATEADD to > would that then give me any statue that runs out more than 90 days?
visakh16
Very Important crosS Applying yaK Herder
52326 Posts
Posted - 2012-05-07 : 16:57:30
quote:Originally posted by FightingTiger Another question just to make sure I am seeing this right. IF I were to change the < before the DATEADD to > would that then give me any statue that runs out more than 90 days?
'if you change it to > then it will retrieve all details which happened since currentdate-90------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/