public static int PayableMonthsInDuration(DateTime StartDate, DateTime EndDate){ int sy = StartDate.Year; int sm = StartDate.Month; int count = 0; do { count++;if ((sy == EndDate.Year) && (sm >= EndDate.Month)) { break; } sm++;if (sm == 13) { sm = 1; sy++; } } while ((EndDate.Year >= sy) || (EndDate.Month >= sm)); return (count);}
This solution is for Rental/subscription calculation, where difference doesn't means to be subtraction, it's meant to be the span in within those two dates.