Sub topic 12
Time and Elapsed-Time Formats
This chapter assumes you know that Excel stores dates as serial numbers and that a number format changes only the display. It also assumes you can apply a custom format in Format Cells. Here you will see how Excel stores times and how to display clock times and totals of elapsed time.
Times are fractions of a day
Excel stores a time as a fraction of one day. Midnight is 0, noon is 0.5, and 6:00 PM is 0.75. A date and a time combine in one number. For example, 45292.75 is 1 January 2024 at 6:00 PM under the default 1900 date system.
Because the value is a number, you can do arithmetic on it. Subtract a start time from an end time to get a duration, which is also a fraction of a day.
Common time codes
| Code | Meaning | Example |
|---|---|---|
| `h` | Hour without leading zero | 9 |
| `hh` | Hour with leading zero | 09 |
| `m` / `mm` | Minute | 5 / 05 |
| `s` / `ss` | Second | 7 / 07 |
| `AM/PM` | Switches to a 12-hour clock | 9:05 PM |
Excel reads m as minutes only when it follows h or precedes s. Otherwise it reads m as a month. So h:mm shows hours and minutes, but mm:ss on its own is read as minutes and seconds only because of the ss.
Elapsed time with square brackets
A plain h code restarts at 0 after 24 hours. If you sum 30 hours and 15 minutes of work, h:mm displays 6:15, because the 24 whole hours are treated as a day. Square brackets tell Excel to show the total count instead:
[h]:mmThis displays 30:15. You can also use [m] for total minutes and [s] for total seconds. Only the first unit in a format can be in brackets.
Worked example
Suppose A2 holds a start of 8:30 AM and B2 holds an end of 5:15 PM.
- In C2, enter
=B2-A2. - Apply the format
h:mm. The result is 8:45.
To total several shifts, use =SUM(C2:C6) and apply [h]:mm. Without the brackets, a total over 24 hours shows the wrong hours.
To convert a duration to decimal hours, multiply by 24:
=(B2-A2)*24Format this cell as Number. If it still shows a time, Excel copied the time format from the inputs.
Common errors
- Negative times show ####. Under the 1900 date system, a time below zero cannot be displayed. This happens when the end time is earlier than the start, such as a shift that passes midnight. Use
=MOD(B2-A2,1)to wrap the result into a valid duration. - Totals look too small. You used
h:mmwhere[h]:mmwas needed. - Times typed as text. A value that is left-aligned and will not add up is text. A later chapter covers converting it.
Exercise
Cells C2:C4 hold daily durations of 9:30, 10:15, and 11:00. Their sum is in C5. Which format shows the correct total, and what does it display?
Show answer
Use [h]:mm. The total is 30 hours 45 minutes, so it displays 30:45. The format h:mm would show 6:45 because it drops the full 24 hours.