Excel Time Calculation: Formulas for Hours and Shifts

Formulas & functions · Updated December 2, 2026

In Excel, subtract a start time from an end time to calculate elapsed time: if A2 contains the start and B2 the end, enter =B2-A2 in C2, then format C2 as [h]:mm to show total hours and minutes. If a shift ends after midnight, use =MOD(B2-A2,1) instead; multiply the result by 24 when you need decimal hours for a calculation such as pay.

How Excel stores time

Excel stores dates and times as numbers. A date is counted as a serial day, and a time is the fraction of a day: midnight is 0, noon is 0.5, and 6:00 a.m. is 0.25. This is why subtracting one time from another produces a fraction rather than a number that visibly looks like hours.

Cell formatting changes how that number appears, not the underlying value. A duration of 7 hours and 30 minutes is stored as 0.3125 days. Formatting it as a time displays a clock-style value, while multiplying it by 24 gives 7.5 hours.

Calculate elapsed time during the same day

Enter valid times in two cells, for example 9:15 AM in A2 and 5:45 PM in B2. In C2, enter =B2-A2. The elapsed time is 8 hours and 30 minutes. Excel may initially display the result as a time of day, such as 8:30 AM, so apply a duration format:

  1. Select the result cell or range.
  2. Press Ctrl+1 on Windows to open Format Cells. On Mac, use Command+1.
  3. Choose Custom and enter [h]:mm in the Type box, then select OK.

Square brackets around h are important: they tell Excel to show elapsed hours without resetting to zero after 24. The built-in format h:mm can display ordinary durations correctly below 24 hours, but longer totals wrap around. For example, a 27-hour total may appear as 3:00 with h:mm, but as 27:00 with [h]:mm.

Handle overnight shifts and date changes

When a shift starts at 10:00 PM and ends at 6:00 AM, direct subtraction produces a negative result because Excel treats both entries as times on the same date. If the shift is known to end the following day, use =MOD(B2-A2,1). With A2 equal to 10:00 PM and B2 equal to 6:00 AM, the result is 8:00.

MOD is convenient for a single overnight interval, but it assumes the elapsed time is less than 24 hours. If a job can last 24 hours or more, enter full date-and-time values instead. For example, with the start date and time in A2 and the end date and time in B2, calculate =B2-A2 and format the result as [h]:mm. Entering dates as well as times removes ambiguity about which day an event belongs to.

For a shift that might cross midnight but has an explicit start and end date, keep both date-time values. Do not use MOD to conceal missing or incorrect dates: it can turn a data-entry error into a plausible-looking duration.

Convert time into decimal hours or minutes

Decimal hours are often useful for timesheets, rates, and summaries. With the elapsed-time result in C2, enter =C2*24 in D2. If C2 represents 8 hours 30 minutes, D2 returns 8.5. Format D2 as Number, rather than as a time, and choose the desired number of decimal places.

To convert the same duration to minutes, multiply by 1,440, the number of minutes in a day. With the duration in C2, use =C2*1440. An 8-hour-30-minute duration returns 510 minutes. Keep the original duration as a time value if you also need to display it as hours and minutes; the decimal conversion is a separate representation of the same amount.

For a simple pay calculation, multiply decimal hours by an hourly rate. If D2 contains 8.5 hours and E2 contains an illustrative rate of 20, =D2*E2 returns 170. This is only a spreadsheet calculation: actual pay rules, breaks, overtime, and rounding depend on the applicable agreement and local requirements.

Add durations and calculate breaks

To total several daily durations, sum the duration cells. If C2:C6 contain each day’s elapsed time, enter =SUM(C2:C6) in C7 and format C7 as [h]:mm. For example, durations of 7:30, 8:00, 6:45, 8:15, and 7:00 total 37:30. The bracketed format keeps the weekly total from wrapping at 24 hours.

For a break deduction, calculate the elapsed shift first, then subtract the break duration. If A2 is the start, B2 the finish, and D2 contains a break duration such as 0:30, enter =B2-A2-D2 for a same-day shift. For a known overnight shift, use =MOD(B2-A2,1)-D2. Format the result as [h]:mm. Make sure the break is entered as a duration, not as a time of day.

If breaks are recorded as clock-in and clock-out times, calculate the break duration by subtracting its start from its end, then deduct that result from the shift duration. Consistent columns and formats make it easier to audit each part of the calculation.

Common time-calculation problems

  • The result shows as a date or clock time: Apply a duration format such as [h]:mm, or use Ctrl+1 on Windows and Command+1 on Mac to choose a custom format.
  • The result is a row of number signs: The column may be too narrow, or the result may be a negative time under the workbook’s date system. Widen the column and check the start, end, and date entries.
  • A time is treated as text: A value pasted with an apostrophe or an unrecognized format may not be a real Excel time. Re-enter it in a recognizable form such as 8:30 AM, or convert the source data before calculating.
  • Totals stop at 24 hours: Change h:mm to [h]:mm. The brackets show cumulative hours rather than the hour on a 24-hour clock.
  • Results are off by a day: Check whether the shift crosses midnight and whether full dates are required. MOD is suitable for a known overnight interval under 24 hours; date-time values are safer for longer or irregular periods.

Frequently Asked Questions

How do I calculate hours between two times in Excel?
Subtract the start time from the end time, such as =B2-A2, and format the result as [h]:mm. Multiply the result by 24 if you need decimal hours.

How do I calculate time in Excel when the shift ends after midnight?
For a known overnight shift shorter than 24 hours, use =MOD(B2-A2,1). If the interval might be 24 hours or longer, enter the start and end dates as well as the times, then subtract the full date-time values.

How do I total more than 24 hours?
Use a SUM formula, for example =SUM(C2:C6), and format the total cell as [h]:mm. Without the brackets, Excel may display only the remainder after each 24-hour period.

How do I show time as a decimal?
Multiply a duration by 24. For example, if C2 contains 8:30, =C2*24 returns 8.5; format the result as a number.

Can Excel calculate hours and minutes separately?
Yes. Keep the duration formatted as [h]:mm for a combined display, or convert it to decimal hours or total minutes for further calculations. Avoid treating the displayed text as the numeric duration.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.