Sub topic 7
Working with Times of Day and Durations
This chapter assumes that you can enter formulas, use relative and absolute cell references, and apply number formats from the Format menu.
Google Sheets stores a time as a fraction of a day. Midnight is 0, noon is 0.5, and 6:00 PM is 0.75. A date-time value combines a whole-number date with a fractional time. For example, the value for one day after midnight plus six hours is 1.25.
The stored number and the displayed value are different. A cell can store 0.5 and display 12:00:00 PM, 12:00, or 50%, depending on its format.
Create times with `TIME`
Use TIME(hour, minute, second) to create a time value from separate numbers. This avoids relying on how typed text is interpreted.
=TIME(14, 30, 0)This creates 2:30 PM. To display it clearly, select the cell and choose Format > Number > Time or apply a custom format such as HH:mm.
You can also create a date-time value by adding a time to a date:
=DATE(2026, 11, 28) + TIME(14, 30, 0)The result is November 28, 2026 at 2:30 PM.
Calculate durations
Subtract an earlier date-time from a later date-time. The result is measured in days, including a fractional part for the time.
Suppose A2 contains 09:15 and B2 contains 17:45.
=B2 - A2The stored result is 0.3541667, which represents 8.5 hours. Format the result as Duration to display 8:30:00.
To return the duration directly in hours, multiply by 24:
=(B2 - A2) * 24To return minutes, multiply by 1,440, the number of minutes in a day:
=(B2 - A2) * 1440| Calculation | Formula | Result |
|---|---|---|
| Duration display | `=B2-A2` | 8:30:00 |
| Decimal hours | `=(B2-A2)*24` | 8.5 |
| Total minutes | `=(B2-A2)*1440` | 510 |
A duration can exceed 24 hours. Use the custom number format [h]:mm:ss when you want total hours rather than a clock that resets after 24 hours. For example, a 27-hour duration displays as 27:00:00 with [h]:mm:ss, but may display as 3:00:00 with a normal time format.
Handle work that crosses midnight
If a shift starts at 10:00 PM and ends at 6:00 AM, directly subtracting the times gives a negative result. Add one day when the end time is earlier than the start time:
=IF(B2<A2, B2+1-A2, B2-A2)This returns eight hours for the overnight shift. The formula treats B2 as belonging to the following day only when it is earlier than A2.
Extract parts from a duration
For a date-time value, HOUR, MINUTE, and SECOND return the clock components:
=HOUR(A2)
=MINUTE(A2)
=SECOND(A2)For a duration longer than one day, use arithmetic when you need total hours or minutes. HOUR returns only the hour portion shown within a 24-hour cycle. Use INT to find whole days and MOD to find the remaining time:
=INT(B2-A2)
=MOD(B2-A2, 1)Format the second result as hh:mm:ss.
Exercise
A2 is 21:30 and B2 is 05:15 on the following day. Which formula calculates the elapsed time correctly?
Show answer
Use =IF(B2<A2, B2+1-A2, B2-A2), then format the result as Duration. It returns 7:45:00.