To calculate the number of hours between two times in Google Sheets, subtract the start time from the end time and multiply the result by 24. For example, if your start time is in cell A2 and your end time is in cell B2, the formula is =(B2-A2)*24. This conversion is necessary because Google Sheets treats one whole day as the integer 1; multiplying by 24 converts that fractional day into decimal hours.

What You'll Need

  • A Google account with access to Google Sheets.
  • A dataset containing start times and end times.
  • Basic familiarity with entering formulas into cells.

Step-by-Step

  1. Set Up Your Columns: Create a clear structure for your data. Label column A as "Start Time," column B as "End Time," and column C as "Total Hours." This organization ensures that your formulas reference the correct cells and makes the sheet easier to audit.
  2. Enter Your Time Data: Input your times using a recognized format. For example, type "8:00 AM" or "17:00" (for 24-hour time). Ensure you include the space before AM or PM so Google Sheets recognizes the entry as a "Time" value rather than plain text. If the time is aligned to the right of the cell, Google Sheets has successfully recognized it as a numerical time value.
  3. Apply the Basic Subtraction Formula: Click on cell C2 (the Total Hours column). Type the equals sign = to start the formula, then click cell B2, type a minus sign -, and click cell A2. The formula should look like =B2-A2. Press Enter. At this stage, the result will likely look like a time (e.g., 8:00:00) because Google Sheets automatically applies a time format to the result of a time subtraction.
  4. Convert Time to Decimal Hours: To use these hours for payroll or billing, you need a decimal number (e.g., 8.5 hours instead of 8:30). Wrap your subtraction in parentheses and multiply by 24. Change your formula to =(B2-A2)*24. This tells Google Sheets to take the fraction of the day and convert it into hours.
  5. Adjust the Cell Formatting: After multiplying by 24, the cell might still be formatted as a "Time" or "Date," resulting in a strange number or a date from the year 1899. To fix this, select the cell, go to the top menu, select Format > Number, and choose "Number." This will display the result as a standard decimal (e.g., 8.00).
  6. Handle Overnight Shifts (The MOD Formula): If a shift starts at 10:00 PM and ends at 6:00 AM the next day, a simple subtraction will result in a negative number. To solve this, use the MOD function. Replace your formula with =MOD(B2-A2, 1)*24. The MOD(..., 1) part ensures that if the result is negative, it wraps around to a positive value, correctly calculating the hours across midnight.
  7. Calculate the Grand Total: To find the total hours for a week or month, use the SUM function at the bottom of your Total Hours column. For example, =SUM(C2:C10). Ensure this total cell is also formatted as "Number" (Format > Number > Number) so it doesn't reset to zero after reaching 24 hours.

Common Mistakes

One of the most frequent errors is forgetting the parentheses in the multiplication formula. If you write =B2-A2*24, Google Sheets follows the mathematical order of operations (PEMDAS), meaning it will multiply A2 by 24 first and then subtract that huge number from B2, leading to a massive negative number. Always group the subtraction first: (B2-A2).

Another common mistake is entering times as text. If you type "8am" without a space, or use a non-standard format, Google Sheets treats the entry as a string of characters. You cannot perform math on text. You can tell if this is happening because text is usually left-aligned in a cell, while numbers and times are right-aligned. If your formula returns a #VALUE! error, check that your input cells are actually formatted as times.

Users also frequently forget to change the formatting of the result cell. When you subtract two times, Google Sheets assumes you want the answer to be a time. When you multiply by 24, it may still try to display that number as a time or date. This is not a formula error, but a display error. Switching the format to "Number" is a critical final step.

Tips

For those managing complex timesheets, consider adding a "Break" column. If employees take a 30-minute unpaid lunch, create column D for "Break Duration" (entered as hours, e.g., 0.5). Your final formula would then be =((B2-A2)*24)-D2. This keeps your data transparent and allows you to adjust break times without changing the start and end times.

To speed up the process, use the "Fill Handle." Once you have written the correct formula in cell C2, click the small blue square in the bottom-right corner of the cell and drag it down to the bottom of your list. Google Sheets will automatically adjust the cell references (B3-A3, B4-A4, etc.) for every row.

If you are working with very large datasets, use an ArrayFormula to calculate the entire column at once. Instead of dragging the formula down, you can use =ARRAYFORMULA(IF(A2:A="", "", (B2:B-A2:A)*24)). This will automatically calculate hours for every row where there is a start time, saving you from manually updating the sheet as you add new entries.

Troubleshooting

If your formula is returning a #VALUE! error, the most likely cause is that one of your cells contains text instead of a valid time. Double-check your entries for typos or missing spaces (e.g., "9:00AM" instead of "9:00 AM"). You can use the =ISNUMBER(A2) formula in a blank cell to test if Google Sheets recognizes your time as a number; if it returns FALSE, the time is being treated as text.

If you see a result like "12:00 AM" or a date like "12/30/1899" after multiplying by 24, your formula is working, but your formatting is wrong. Navigate to Format > Number and select "Number." This forces the sheet to show the raw decimal value rather than attempting to interpret it as a calendar date.

If your total hours are resetting every 24 hours (e.g., a total of 26 hours is showing as 2 hours), this is because the cell is formatted as "Time." In the Format > Number menu, you can select "Duration." This tells Google Sheets to accumulate hours beyond a single day rather than wrapping back around to zero.

Frequently Asked Questions

Why do I have to multiply by 24?

Google Sheets stores time as a fraction of a 24-hour day. For example, 12:00 PM is stored as 0.5. If you subtract two times and get 0.333, that represents one-third of a day. Multiplying by 24 converts that fraction into the actual number of hours (8 hours).

How do I calculate hours if the shift crosses midnight?

Use the MOD function: =MOD(End_Time - Start_Time, 1) * 24. The MOD function with a divisor of 1 ensures that negative results (which happen when the end time is numerically smaller than the start time) are converted into the correct positive difference.

Can I calculate hours using only minutes?

Yes. Instead of multiplying by 24, multiply the subtraction result by 1440 (which is 24 hours * 60 minutes). The formula would be =(B2-A2)*1440. Ensure the cell is formatted as a "Number."

How do I subtract a lunch break from the total?

The simplest way is to enter the break as a decimal (e.g., 0.5 for 30 minutes) in a separate cell and subtract it from your final hour calculation: =((B2-A2)*24) - Break_Cell.

What is the difference between "Time" and "Duration" formatting?

"Time" formatting is used for a specific point in the day (e.g., 3:00 PM). "Duration" formatting is used for an elapsed amount of time (e.g., 35 hours and 10 minutes). Use Duration for your total sums to avoid the 24-hour reset.