Quantcast
Channel: All Developer posts
Viewing all articles
Browse latest Browse all 48670

Re: Number of Months between two dates

$
0
0

I had a similar question, but for my case, I want the formula to be sensitive to the day of month as well as the month of the year. For this, I added an offset of -1 to your formula above any time the day of the end date is less than the day of the start date.

 

So number of months between Jan 15 and Feb 10 is "0", while number of months between Jan 15 and Feb 20 is "1".

 

   (12*(Date.Year([EndDate])-Date.Year([StartDate])))

+ (Date.Month([EndDate]) - Date.Month([StartDate]))

+ (if Date.Day([EndDate]) < Date.Day([StartDate]) then -1 else 0)

 


Viewing all articles
Browse latest Browse all 48670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>