DateTime d1 = new DateTime(2020, 1, 1); DateTime d2 = new DateTime(2020,12,31); // subtract the dates, and divide the total days by 30.4 (avg number of days per month) int months = (int)(Math.Floor(((d2-d1).TotalDays / 30.4)));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)