troubleshooting Question

Previous month start and end dates

Avatar of fahVB
fahVB asked on
Microsoft SQL Server 2005
9 Comments1 Solution489 ViewsLast Modified:
I have several update stmts where i am manually entering a previous month start and end date
e.g
and v.effective between '06/01/2008' and '06/30/2008'

i have this stmt which actually calls the current month start and end date,

Declare @StartDate datetime
declare @EndDate datetime
set @startdate = dateadd(dd,1 - datepart(dd,getdate()),getdate())
set @enddate = dateadd(dd,- datepart(dd,dateadd(mm,1,getdate())),dateadd(mm,1,getdate()))
select @StartDate, @EndDate

my question is how should i change the above so it calls previous month start and end dates, so i can just place this in my update stmts

e.g.
and v.effective between @StartDate and @EndDate

Thank you...




Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
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 1 Answer and 9 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