Wednesday, April 7, 2010

Difference Between two Dates in asp.net

There are two textbox in which there are dates:
Following c# coding will calculate days between these two date and will display in Label.



DateTime dt1=Convert.toDateTime(TextBox1.text);

DateTime dt2=Convert.toDateTime(TextBox2.text);
TimeSpan ts=dt2.Substract(dt1);
Label1.text=ts.days.toString();

No comments:

Post a Comment