var startDate = new DateTime(2021, 1, 1); var endDate = DateTime.Now; var diffMonth = (int)((endDate - startDate).Days / (365.25 / 12));