ericauv
ericauv

Reputation: 170

Check if Date is 2 months prior to today's date

I want to check if a variable date is in the month that is two months prior to today's date.

Is there a way (using a built in date funciton like dateadd()) to cover the edge cases of when month(now())=1 or month(now())=2 in more elegant manner than the following?

?format(month(now()) & " " & year(now()),"MMMM YYYY")=format(dateadd("M",2,format(varMonth & " " & varYear, "MMMM YYYY")),"MMMM YYYY")

Upvotes: 0

Views: 843

Answers (1)

Vincent G
Vincent G

Reputation: 3188

You can use the DateDiff function with the "m" interval to calculate the difference in months between two dates.

Upvotes: 2

Related Questions