Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Google Sheets Time Duration Formulas: How-To Guide

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To calculate a time duration in Google Sheets, subtract the start time from the end time and format the result as a duration: enter =B2-A2 (where A2 is start and B2 is end), then select the cell and choose Format > Number > Duration. If the end time crosses midnight, use =MOD(B2-A2,1) or add 1 to the end time. For durations entered as hours and minutes, multiply by 24 to get decimal hours, or use TEXT to display as h:mm. The steps below cover the reliable formulas and formatting so your totals add up correctly.

What You'll Need

  • A Google account with access to Google Sheets (desktop browser or the mobile app).
  • Start and end times entered in a consistent format, such as 9:00 AM and 5:30 PM, or 24-hour times like 09:00 and 17:30.
  • Basic familiarity with cell references (A2, B2) and the formula bar.

Step-by-Step

  1. Enter your start and end times. Put start times in column A and end times in column B, starting from row 2. Type times with AM/PM or in 24-hour format. Google Sheets recognises both. If you type 9:00 it may interpret it as 9:00 AM; to avoid ambiguity, type 9:00 AM or format the column as time first (Format > Number > Time).
  2. Write the subtraction formula. In cell C2, enter =B2-A2. Press Enter. This returns a fraction of a day, which Sheets can display as a duration once formatted. If the result shows a time like 8:30 AM, that is the correct value but the wrong display format; the next step fixes it.
  3. Format the result as a duration. Select C2 (or the whole C column), then choose Format > Number > Duration. The value now appears as 8:30:00 or similar. Duration format shows hours, minutes, and seconds without AM/PM. Menu labels can differ slightly by version, device, or region, but the Format > Number path is standard on desktop.
  4. Handle overnight shifts. If the end time is earlier than the start time (for example 10:00 PM to 6:00 AM), plain subtraction returns a negative value that displays as ###### or an error. Use =MOD(B2-A2,1) instead. The MOD function wraps the negative result into a positive duration. Alternatively, enter the end time as 6:00 AM on the next day by adding 1: =(B2+1)-A2.
  5. Convert duration to decimal hours. To get a number like 8.5 for payroll or billing, multiply the duration by 24: =(B2-A2)*24. Format the result as a plain number (Format > Number > Number). For decimal minutes, multiply by 1440 (minutes in a day).
  6. Sum multiple durations. If C2:C10 contains durations, use =SUM(C2:C10) and format the total as Duration. If the total exceeds 24 hours, Duration format still shows the full amount (for example 27:30:00). If you see a time like 3:30 AM, the cell is formatted as Time, not Duration; reapply Duration format.
  7. Display hours and minutes only. To show 8:30 instead of 8:30:00, use a custom format: select the cell, choose Format > Number > Custom number format, and enter [h]:mm. The square brackets tell Sheets to show elapsed hours beyond 24. You can also use =TEXT(B2-A2,"[h]:mm") to produce a text string, but text results cannot be summed.
  8. Calculate duration from a start time and a number of hours. To find an end time, use =A2 + TIME(2,30,0) for 2 hours 30 minutes, or =A2 + 2.5/24 for 2.5 hours. Format the result as Time.
  9. Check for text vs. time values. If subtraction returns #VALUE!, one cell likely contains text. Click the cell and look at the formula bar: a real time appears as 9:00:00 AM; text may appear with an apostrophe or as plain text. Re-enter the time or use TIMEVALUE to convert a text string, for example =TIMEVALUE("9:00 AM").

Common Mistakes

  • Leaving the result formatted as Time. A duration of 25 hours displays as 1:00 AM under Time format. Always apply Duration or a custom [h]:mm format to totals.
  • Forgetting MOD for overnight shifts. Plain subtraction across midnight gives a negative value and an error display. Use =MOD(end-start,1).
  • Mixing text and time values. Times imported from other systems may be text. Subtraction fails with #VALUE!. Convert with TIMEVALUE or re-enter.
  • Using decimal hours without converting. Typing 8.5 in a Time-formatted cell is interpreted as 8.5 days, not 8.5 hours. Keep decimal hours in a Number-formatted cell.
  • Assuming SUM works on text durations. If you used TEXT to display durations, the results are text and SUM returns 0. Keep numeric durations and format them instead.

Tips

  • Use ARRAYFORMULA to fill a whole column: =ARRAYFORMULA(IF(B2:B="","",MOD(B2:B-A2:A,1))).
  • Press Ctrl+Shift+: (Windows) or Cmd+Shift+: (Mac) to insert the current time quickly.
  • To round a duration to the nearest 15 minutes, use =MROUND(B2-A2,1/96) and format as Duration. 1/96 of a day is 15 minutes.
  • For payroll, keep raw durations in one column and decimal hours in another; do not overwrite the duration with a number.
  • Name your ranges (Data > Named ranges) to make SUM formulas easier to read.

Troubleshooting

  • Result shows ######: The column is too narrow or the value is negative. Widen the column; if negative, apply MOD.
  • Result shows a time like 4:30 PM: The cell is Time-formatted. Change to Duration.
  • #VALUE! error: One input is text. Check the formula bar and re-enter or use TIMEVALUE.
  • Total is wrong after summing: Some cells may be text or Time-formatted. Select the range and confirm all are Duration-formatted numbers.
  • Times entered as 9.00: Sheets may read this as a number, not a time. Use a colon (9:00) or AM/PM.
  • Mobile app formatting: In the Sheets mobile app, tap the cell, tap the format icon (letter A with lines), and choose Number > Duration. Labels vary by platform.

Frequently Asked Questions

Why does my duration show as a date or time?

Because the cell is formatted as Date or Time. Select it and apply Format > Number > Duration.

How do I calculate hours worked across midnight?

Use =MOD(B2-A2,1) and format as Duration. This handles end times earlier than start times.

How do I convert a duration to decimal hours?

Multiply by 24: =(B2-A2)*24. Format the result as a plain number.

Can I sum durations over 24 hours?

Yes. Sum the duration cells and format the total as Duration. It will display elapsed hours such as 30:15:00.

How do I show only hours and minutes without seconds?

Use a custom number format of [h]:mm on the duration cell.

Why does SUM return 0 for my durations?

The durations are probably text, often created with the TEXT function. Keep numeric durations and format them instead of converting to text.