In addition to Solution 1: I hope you are using not with strings representing date/time, but with the type
System.DateTime
. It defines the '-' subtraction operator which should be used to find out the time difference; the type of result is
System.TimeSpan
. Using the operator is much clearer than calling the
Subtract
function:
https://msdn.microsoft.com/en-us/library/system.datetime%28v=vs.110%29.aspx[
^],
https://msdn.microsoft.com/en-us/library/system.timespan%28v=vs.110%29.aspx[
^].
Nowhere in intermediate results should you use strings representing time or duration, but the type of the cell in the grid view could be string, if you only use it for on-screen output.
—SA