Hard to say without seeing more of the stored proc, but if I had to guess, I would say it is what I have highlighted in RED that you should look at. That -2 in there is subtracting 2 years, so if you change that to -5, that may be what you need.DECLARE @Comp1StartDate datetime,@Comp2StartDate datetime,@Comp1EndDate datetime,@Comp2EndDate datetime/*Set the comparison dates to look at the same time period for the previous two years*/SELECT @Comp1StartDate = Dateadd(year, -1, @startdate), @comp2StartDate = dateadd(year, -2, @startdate),@Comp1EndDate = dateadd(year, -1, @enddate), @comp2EndDate = dateadd(year, -2, @enddate)
BTW, I think the minus sign after comp2StartDate should not be a minus sign, it should be an = sign.Then again, I am guessing :--)