# Calculating Time Differences

If you want to calculate time differences, for example, the time between 23:30 and 01:10 in the same night, use the following formula:

=(B2<A2)+B2-A2

The later time is B2 and the earlier time is A2. The result of the example is 01:40 or 1 hour and 40 minutes.

In the formula, an entire 24-hour day has a value of 1 and one hour has a value of 1/24. The logical value in parentheses is 0 or 1, corresponding to 0 or 24 hours. The result returned by the formula is automatically issued in time format due to the sequence of the operands.