Showing posts with label Getting months between two dates. Show all posts
Showing posts with label Getting months between two dates. Show all posts

Monday, February 15, 2010

Getting months between two dates

DateTime dt1 = DateTime.Parse("15-04-2010");
DateTime dt2 = DateTime.Parse("15-09-2007") ;
int months = dt1.Month - dt2.Month;
int years = dt1.Year - dt2.Year;
months += years * 12;