There's 3 cases: same year, previous year and other years.
If the day of the month does not matter...
public int GetTotalNumberOfMonths(DateTime start, DateTime end){ // work with dates in the right order if (start > end) { var swapper = start; start = end; end = swapper; } switch (end.Year - start.Year) { case 0: // Same year return end.Month - start.Month; case 1: // last year return (12 - start.Month) + end.Month; default: return 12 * (3 - (end.Year - start.Year)) + (12 - start.Month) + end.Month; }}