To to find date difference in C#

This code sample shows how to find the difference between two dates in C#



DateTime dt = Convert.ToDateTime("01/01/2008");
DateTime dt1 = Convert.ToDateTime("05/03/2008");
TimeSpan ts = dt.Subtract(dt1);
int day = ts.Days;
textBox1.Text = day.ToString();


Comments

No responses found. Be the first to comment...