Problem:

In order to calculate the difference between two time values, the earlier time must be subtracted from the later one.
However, using this method when the later time is actually the next day, will result in an error (negative time).
How could we avoid such errors when calculating the difference between any two time values?

Solution:

Using this MOD formula:
=MOD(B2-A2,1)

Format:
Apply hh:mm format to cells contains the formula above.