Forum Discussion
trevb
10 years agoAdvocate II
Number of Months between two dates
This seems like a really dumb thing to be asking. I need to count the number of Months between two dates. I can happily find out the number of days, but that doesn't help much as number of days ...
drmbrklyn
9 years agoFrequent Visitor
I use this formula in a calucated column of my date table:
OrdMonth = if(today()<CAL[Date],datediff(today(),CAL[Date],MONTH),datediff(CAL[Date],today(),MONTH)*-1)
It returns:
0 if the date is in the current month
-1 if the date is in the previous month
+1 if the dates in the next month
Its' great to filter for windows of time (last three months, within 3 months before and after)
It's easy to adapt for use with Years, Days or Weeks.
You can also swap out the "Today" argument for a different, specific date.
This also solves the issue with datediff where the start date cannot be after the end date.