Function durationToMonths