As an example I have 2 columns, A and B – both respectively titled Date and Time.
In A2 I have:
4/03/2012
In A3 I have:
8/03/2012
In B2 I have:
20:34:09
And finally in B3 I have:
17:35:40
So basically I’d like to find out the time between “4/03/2012 20:34:09” and “8/03/2012
17:35:40”.
Currently I have: =(A3+B3)-(A2+B2) in the cell A5.
This works as it shows “3/01/1900 21:01” which is the day and time difference between the two.
Also in cell A6 I have a formula which represents this in a nice format:
=TEXT(A5, “dd hh:mm:ss”). So the above result looks like “03 21:01:31”.
However the problem occurs when A3 is changed to “4/03/2012”.
Since now A6 shows “#VALUE!” when it should show: 00 02:58:29
. Also A5 shows #####…..etc
I am not quite sure on how to solve this problem. Any suggestions would be appreciated!
Well, I don’t have the best reasoning behind why this is happening, but one solution would be to combine the date and time in an intermediate cell, then calculate the difference off those two intermediate cells.
So for example, in C2 put
=A2+B2and in C3 put=A3+B3and then in A5 put=C3-C2. Now the unformatted value will actually calculate correctly. Finally, change your text formatting to be something like this:=TEXT(ABS(A5), IF(A5<0,"-","") & "dd hh:mm:ss")This will display the time difference formatted like before but with the negative sign if needed.
(Would love to hear if someone can explain the details as to why this is happening.)