how to calculate total days from starting date to end date in c#,.net?
- by Rishabh jain
i m making a project in which i have to calculate total number of days from starting date to ending date which are inserted in text box by user at run time in asp.net c#.i have to do this on button_click event.how to do this?
i tried this-
protected void TextBox14_TextChanged(object sender, EventArgs e)
{
// get date from first text box
DateTime dold = Convert.ToDateTime(TextBox1.Text);
DateTime dnew = Convert.ToDateTime(TextBox14.Text);
TimeSpan daydif = (dnew - dold);
double dayd = daydif.TotalDays;
Label27.Text = dayd.ToString();
}