troubleshooting Question

2 dates in a SQL stored proc - 7 days prior and 30 days in future

Avatar of James Murphy
James MurphyFlag for Australia asked on
Microsoft SQL ServerSQL
4 Comments2 Solutions75 ViewsLast Modified:
Hi,

I have a new for 2 dates in my SQL stored procedure.  
1) 7 Days prior to today
2) 30 days in the future from today.

I am using these, but they don't seem to be working:
      DECLARE @7daysago DATE = CONVERT(DATE, DATEADD(DAY, -DAY(GETDATE()) -7, DATEADD(MONTH, 1, GETDATE())));
      DECLARE @30daysinfuture DATE = CONVERT(DATE, DATEADD(DAY, -DAY(GETDATE()) +30, DATEADD(MONTH, 1, GETDATE())));

Could anyone please point me in the right direction?

cheers
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros