Take the 2-minute tour ×  How do I find the time difference
between two datetime objects in ASP.NET?  share|improve this
question add comment  7 Answers  up vote 40 down vote accepted
The following example demonstrates how to do this:  DateTime a =
new DateTime(2010, 05, 12, 13, 15, 00); DateTime b = new
DateTime(2010, 05, 12, 13, 45, 00);  When executed this prints
"30" since there is a 30 minute difference between the
date/times.  The result of DateTime.Subtract(DateTime x) is a
Timespan object which gives other useful properties.
share|improve this answer You want TotalMinutes, not Minutes -
the latter returns the minute component of the TimeSpan, e.g. 10
in 1:10:32 –  Ben M May 12 '10 at 17:13 this is what i want – 
MarsMan May 12 '10 at 17:19 To display the difference, do
something like this:Console.WriteLine((a -
b).ToString(@"hh\:mm\:ss")). See: MSDN Custom TimeSpan Format – 
ishmael Nov 5 '12 at 20:07 add comment  You want the TimeSpan
struct:  TimeSpan diff = dateTime1 - dateTime2;   There are vari