If you want to find the date time difference between two dates, the best way would be to use TimeSpan class.
Take a look at the following simple example:
//difference with DateTime.Now (now its 2011-02-02 00:40);
string firstDate = "2011-01-05 09:18:55";
TimeSpan ts = new TimeSpan();
ts = DateTime.Now.Subtract(Convert.ToDateTime(firstDate));
Response.Write("The difference is: " + ts.Days +" day(s), "+ ts.Hours + " hour(s), "
+ ts.Minutes +" minute(s), "+ ts.Seconds + " second(s) "+ ts.Milliseconds + " milliseconds");
The result is: The difference is: 27 day(s), 15 hour(s), 22 minute(s), 5 second(s) 299 milliseconds
This comment is awaiting moderation.
What kind of email newsletter would you prefer to receive from CodeAsp.Net?