This exercise will teach how to get the months difference between From date and To date.
private static int monthDifference(DateTime startDate,
DateTime endDate)
{
int monthsApart = 12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
return Math.Abs(monthsApart);
}
{
int monthsApart = 12 * (startDate.Year - endDate.Year) + startDate.Month - endDate.Month;
return Math.Abs(monthsApart);
}
Hope this helps...
No comments:
Post a Comment