After searching on web I couldn’t find really a nice and decent code to calculate the difference but for my friends here is one for you all:
public int CalulateDifferenceInMonths(DateTime startDate, DateTime endDate)
{
int TotalMonths = 12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
return Math.Abs(TotalMonths);
}
1 comment:
Really interesting I was trying to do this for long time I did it by diving by number of days which I think is not acurate but thanks for this.
Regards
Andrew
Post a Comment