how to calculate total days from starting date to end date in c#,.net?

Posted by Rishabh jain on Stack Overflow See other posts from Stack Overflow or by Rishabh jain
Published on 2014-08-23T10:08:12Z Indexed on 2014/08/23 10:20 UTC
Read the original article Hit count: 258

Filed under:
|

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();
}

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#-4.0