Here I will do this with in two steps.
In the first step i will convert string to date , data type format.
In the second step i will pass the date to formula to calculate number of days.
Let see how we will do this.
DateTime dtStart = new DateTime();
DateTime dtendDate = new DateTime();
dtStart = Convert.ToDateTime("12-25-2013");
dtendDate = Convert.ToDateTime("12-30-2013");
DateTime d1 = dtStart ;
DateTime d2 = dtendDate ;
TimeSpan t = d1 - d2;
double NrOfDays = t.TotalDays;
string strdays = result.ToString() + " Days between " + NrOfDays.ToString();
In the first step i will convert string to date , data type format.
In the second step i will pass the date to formula to calculate number of days.
Let see how we will do this.
DateTime dtStart = new DateTime();
DateTime dtendDate = new DateTime();
dtStart = Convert.ToDateTime("12-25-2013");
dtendDate = Convert.ToDateTime("12-30-2013");
DateTime d1 = dtStart ;
DateTime d2 = dtendDate ;
TimeSpan t = d1 - d2;
double NrOfDays = t.TotalDays;
string strdays = result.ToString() + " Days between " + NrOfDays.ToString();
No comments:
Post a Comment