DateTime problem???
-
I have two instance of DateTime structure, I want difference between these two dates in no. of days. Compair() is returning 1,-1 but not relative diff. Dateformat mm/dd/yy. Yhankxxxxxxx
Truth Is The Simplest !!!!
-
I have two instance of DateTime structure, I want difference between these two dates in no. of days. Compair() is returning 1,-1 but not relative diff. Dateformat mm/dd/yy. Yhankxxxxxxx
Truth Is The Simplest !!!!
Try: DateTime dt1 = DateTime.Parse("01/01/2008 13:23"); DateTime dt2 = DateTime.Parse("01/01/2008 11:00"); TimeSpan ts = dt1.Subtract(dt2); or you could do: DateTime dt1 = DateTime.Parse("01/01/2008 13:00"); DateTime dt2 = DateTime.Parse("01/01/2008 11:00"); TimeSpan ts = dt1 - dt2; int days = ts.Days; int hrs = ts.Hours; int min = ts.Minutes; int sec = ts.Milliseconds;