Hi, Sushanth!
My two cents.
If subtracting 2 date/time formatted cell values this happens:
C1: =A1-B1
a) if target cell (C1) is formatted as date/time
if the subtrahend (B1) is greater than the minuend (A1), error value is returned
if the subtrahend is less or equal than the minuend, difference (positive) is returned
b) if target cell is formatted as general (or number, but not as date/time)
if the subtrahend is greater than the minuend, difference (negative) is returned
if the subtrahend is less or equal than the minuend, difference (positive) is returned
You can avoid the error value in two ways:
1) quick & dirty
=ABS(A1-B1)
and then you'll have to control/decide how to treat the result in other calculations
2) long
=IF(A1>=B1,A1-B1,B1-A1)
and same as above.
Hope it helps.
Regards!