I need help with calculating the number of months between two dates, inclusive of both extremes. I have attempted the following code:
var duration : moment.Duration;
const contractStartMoment = moment(contractStart); //contractStart=01.05.2021
const contractEndMoment = moment(contractEnd); //contractEnd=31.05.2021
duration = moment.duration(contractEndMoment.diff(contractStartMoment));
var months = duration.asMonths().valueOf();
console.log('months' + ':' + duration.asMonths()); //This prints : 0.9856465225158627
The expected result for months
should be 1 since it represents a complete month, however, I am receiving 0.9856465225158627 instead. Can someone please point out what mistake I might be making here.