Forum Discussion
TomMusto
6 years agoQrew Cadet
I believe the following formula works without having to deal with rounding or using approximations to convert into months:
I spot checked a few dates and it appeared to calculate correctly based on the guidelines you provided. This assumes that you don't want the same rounding on the start date as you do on the end date. If you do want that same rounding, you would need to copy/paste the endMo formula to startMo and replace the field references to reference your start date. Hope this helps.
-Tom
var Number yrDiff = Year([Date End]) - Year([Date Start]);
var Number startMo = Month([Date Start]);
var Number endMo = If(ToNumber(Day([Date End]))/ToNumber(Day(LastDayOfMonth([Date End])))>= 0.5, Month([Date End])+1, Month([Date End]));
$yrDiff*12 + $endMo - $startMo
I spot checked a few dates and it appeared to calculate correctly based on the guidelines you provided. This assumes that you don't want the same rounding on the start date as you do on the end date. If you do want that same rounding, you would need to copy/paste the endMo formula to startMo and replace the field references to reference your start date. Hope this helps.
-Tom