using System.Globalization;
public int DayDifference(string strFromDt, string strToDate)
{
DateTime fromDate
= Convert.ToDateTime(DateTime.ParseExact(strFromDt, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("MM/dd/yyyy", CultureInfo.InvariantCulture));
DateTime toDate
= Convert.ToDateTime(DateTime.ParseExact(strToDate, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("MM/dd/yyyy", CultureInfo.InvariantCulture));
TimeSpan span
= toDate.Subtract(fromDate);
int day
= span.Days;
return day;
}
Note:-
Date format to pass “dd/MM/yyyy”
No comments:
Post a Comment