Reputation: 359
Im looking to report on Month to date(MTD) and previous years MTD
My code for MTD is
WHERE (Month(DateCompleted) = Month(getdate())
AND YEAR (DateCompleted) = YEAR (getdate ()))
Is there a way i can look at last years exact month as this month
for for instance this query above gives me all sales for the month of june 2014 so far. I want to compare them in a dynamic report so i would like to view June 2013 . Cheers
Upvotes: 0
Views: 50
Reputation: 116458
Just subtract 1:
where Month(DateCompleted) = Month(getdate())
and Year(DateCompleted) = Year(getdate()) - 1
Upvotes: 1
Reputation: 3180
It strikes me that simply decrementing the year would do this.
YEAR (DateCompleted) = YEAR (getdate ())-1
Upvotes: 1