Time Calculation Formula in Excel and Everyday Use

Formulas & functions · Updated December 3, 2026

The basic time calculation formula is elapsed time = end time − start time. In Excel, subtract the cell containing the start time from the cell containing the end time; if the result crosses midnight, use =MOD(B2-A2,1), with the start time in A2 and end time in B2.

The Basic Time Calculation

Time calculations usually compare two points on a clock. If a task starts at 9:15 a.m. and ends at 11:45 a.m., subtracting the start from the end gives 2 hours and 30 minutes. The same principle works for travel, meetings, shifts, study sessions, and many other intervals.

For a simple Excel example, enter 9:15 AM in A2 and 11:45 AM in B2. In C2, enter =B2-A2. Format C2 as a time or duration to display the result as 2:30. The formula returns a fraction of a day: 2 hours and 30 minutes is 2.5/24, or about 0.10417.

That underlying representation explains why formatting matters. A result can be mathematically correct but appear as a decimal, a clock time, or a duration depending on its cell format.

How Time Is Represented in Excel

Excel stores dates and times as serial numbers. A whole-number step represents one day, and the fractional part represents the time within that day. Midnight is the start of a day; noon is halfway through it. For example, 6:00 a.m. corresponds to 0.25 of a day, and 6:00 p.m. to 0.75.

When you subtract one time from another, Excel therefore returns a fraction of a day. To display hours and minutes, select the result cell and choose Home > Number, then select a suitable time format. For durations that may exceed 24 hours, use a custom format such as [h]:mm. The brackets tell Excel to show total elapsed hours rather than reset the hour display after each 24-hour period.

For instance, a total of 27 hours and 15 minutes displays as 3:15 with a standard clock format, but as 27:15 with [h]:mm. This is a display difference, not a change to the stored value.

Calculating Time Across Midnight

A direct subtraction can produce a negative result if the end time is after midnight and the start time is before it. For example, entering 10:00 PM in A2 and 6:00 AM in B2 makes =B2-A2 negative, because Excel treats both entries as times on the same date.

If the interval is known to be less than 24 hours, use =MOD(B2-A2,1), with the start in A2 and end in B2. For the example above, it returns 8:00. MOD wraps the negative difference around a full day. Format the result as [h]:mm if totals may later be added together.

If dates are available, it is clearer to enter full date-and-time values and subtract them directly. With a start date and time in A2 and an end date and time in B2, use =B2-A2. For example, a start of November 22 at 10:00 PM and an end of November 23 at 6:00 AM gives 8 hours. The date makes the overnight sequence explicit and avoids ambiguity about whether an interval spans one midnight or several days.

Adding Durations and Converting Units

To add durations, use Excel’s ordinary addition. If individual durations are in C2:C5, enter =SUM(C2:C5) in C6 and format C6 as [h]:mm. This adds all the stored fractions of a day and displays the total hours and minutes, including totals above 24 hours.

To convert an elapsed-time value into a number of hours, multiply it by 24. With the duration in C2, enter =C2*24. If C2 contains 2:30, the result is 2.5 hours. To convert the same duration to minutes, multiply by 1440, the number of minutes in a day: =C2*1440. The result is 150 minutes. Format these converted results as General or Number, not as a time-of-day format.

These conversions are useful when calculating hourly quantities or comparing durations numerically. Keep the original duration available if you also need to show a reader-friendly hours-and-minutes display.

Work Shifts, Breaks, and Rates

For a shift, subtract the start time from the end time, then subtract any unpaid break. If A2 contains a shift start, B2 contains the finish, and C2 contains break length as a duration, use =MOD(B2-A2,1)-C2. Format the answer as [h]:mm. For a shift from 10:00 PM to 6:30 AM with a 30-minute unpaid break, the elapsed span is 8 hours 30 minutes and paid time is 8 hours.

If the break is entered as a number of minutes rather than a time duration, divide it by 1440 before subtracting. With the same start and end cells and 30 in C2, use =MOD(B2-A2,1)-C2/1440. This keeps the units consistent: Excel’s time values are fractions of a day, not raw minute counts.

For a simple illustrative pay calculation, if D2 contains paid hours as a decimal and E2 contains an hourly rate, use =D2*E2. For 8 hours at 20 currency units per hour, the result is 160 currency units. This is only arithmetic; actual pay can depend on employment terms, local rules, overtime, and rounding practices. Check the applicable terms with the employer or a qualified professional.

Common Errors and Practical Checks

  • Wrong format: A value such as 0.25 may mean six hours, not a quarter of an hour. Check the cell format and convert to hours by multiplying by 24 when needed.
  • Unexpected ############: The column may be too narrow, or a date/time result may be negative. Widen the column and verify the date sequence and formula.
  • Totals reset after 24 hours: Apply the custom duration format [h]:mm instead of a standard time-of-day format.
  • Text instead of a time value: Entries imported with inconsistent formats or leading apostrophes may not behave as times. Re-enter them as recognized time values or convert the source data before calculating.
  • Rounding: Displaying only hours and minutes may hide seconds or fractions of a minute. If precision matters, retain the underlying value and choose an appropriate display format rather than rounding prematurely.

For scheduling across daylight-saving changes, time zones, or systems that record timestamps, simple clock subtraction may not tell the whole story. Use dated timestamps with a clearly defined time zone or the relevant system’s rules. A local clock can skip or repeat an hour when daylight-saving time changes, so a time-only entry is not enough to establish the actual elapsed duration.

Frequently Asked Questions

What is the formula for calculating time?
Subtract the start time from the end time: elapsed time = end − start. In Excel, use =B2-A2 when the start is in A2 and the end is in B2.

How do I calculate hours between two times in Excel?
Enter the start and end as valid time values, subtract the start from the end, and format the result as a duration. Multiply the result by 24 if you need decimal hours.

How do I calculate hours when a shift passes midnight?
For a shift shorter than 24 hours with times only, use =MOD(B2-A2,1). If you have full dates as well as times, subtract the dated timestamps directly.

Why does my time total show 3:00 instead of 27:00?
A standard time format repeats after 24 hours. Apply the custom format [h]:mm to show the total elapsed hours.

How do I convert time to decimal hours?
Multiply the Excel duration by 24. A duration of 2:30 becomes 2.5 hours; format the result as a number rather than a clock time.

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.