Search code examples
excelexcel-formulaexcel-2010excel-2007

unable to ignore date while calculating time difference


A2 has 6:04:42 PM B2 has 6:05:02 PM C2 has 10/23/2015 6:04:38 PM In D2 I need a formula that finds difference between A2 and C2 (A2-C2) but when I do that I get ############# because of the date in C2 I believe. I tried changing the format, extracting the timevalue but it is not happening. When I type =TIMEVALUE(C2), it gives me #VALUE!

How can I get the exact difference (0:00:04)

Thanks


Solution

  • You cannot display a negative time. That is the reason behind the #########. You will have to remove the date from C2 and subtract the smaller of the two times from the larger.

    =MAX(MOD(C2, 1), A2)-MIN(MOD(C2, 1), A2)
    

          Negative Time

    The raw value of a negative time can also be resolved. By converting that to its absolute value, you will get a time you can display.

    =ABS(MOD(C2, 1) - A2)