How to Calculate Hours Worked Per Week in Google Sheets

Published on

This tutorial explains how to calculate hours worked per week in Google Sheets using the QUERY function and some simple helper formulas. Before you apply the QUERY, it’s important to structure your data correctly.

Follow along with the step-by-step instructions below. To try it yourself, you can copy the sample sheet.

Sample Data

Assume you have a dataset with the following columns:

  • Date (Column A)
  • Start Time (Column B)
  • End Time (Column C)
Sample data to calculate hours worked per week in Google Sheets

Using this data, you can easily calculate hours worked per week in Google Sheets.

You can also subtract a fixed lunch break (like 1 hour) if needed.

Step 1: Add a Week Number Column

In cell D1, enter the following formula:

=VSTACK("Week #", ARRAYFORMULA(IF(LEN(A2:A), WEEKNUM(A2:A, 1), )))

This formula assigns a week number to each date in column A. By default, the week starts on Sunday. To start the week on Monday, change 1 to 2.

Step 2: Calculate Daily Work Duration in Decimal Format

In cell E1, use this formula:

=VSTACK("Duration", ARRAYFORMULA(IF(LEN(B2:B), C2:C - B2:B, )))

This subtracts the start time from the end time and returns the result in decimal (fraction of a day). For example, 0.2916667 represents 7 hours.

Formatted data to calculate durations per week using QUERY in Google Sheets

Optional: Subtract Fixed Lunch Break

To deduct 1 hour for lunch daily, use:

=VSTACK("Duration", ARRAYFORMULA(IF(LEN(B2:B), C2:C - B2:B - 1/24, )))

For a 30-minute break, replace 1/24 with 0.5/24.

Why Decimal Format?

QUERY requires numerical input, and decimal format is essential. Using VSTACK with a text header and IF ensures the result remains numeric. A plain formula like =ARRAYFORMULA(C2:C - B2:B) may display in time format and won’t work well inside QUERY.

Step 3: Calculate Hours Worked Per Week Using QUERY

Now that your data includes week numbers and durations, run the following QUERY:

=QUERY(D1:E, "SELECT Col1, SUM(Col2) WHERE Col1 IS NOT NULL GROUP BY Col1 FORMAT SUM(Col2) '[h]:mm:ss'", 1)

This will return the total hours worked for each week:

Week #sum Duration
514:00:00
649:00:00
742:00:00

To learn how to rename columns in the result, check out How to Use the Label Clause in Google Sheets Query.

Step 4: Calculate Without Helper Columns (Optional)

If you prefer not to use extra columns, combine the logic using HSTACK and VSTACK:

=ARRAYFORMULA(HSTACK(
   VSTACK("Week #", IF(LEN(A2:A), WEEKNUM(A2:A, 1), )),
   VSTACK("Duration", IF(LEN(B2:B), C2:C - B2:B, ))
))

This creates a dynamic dataset you can plug directly into the QUERY function.

Conclusion

You now know how to calculate hours worked per week in Google Sheets—whether using helper columns or a single combined formula. With small adjustments, you can also deduct breaks or group hours by different date ranges.

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Expert Prashanth KV is a Diamond Product Expert in Google Sheets, officially recognized by Google for his contributions to the Docs Editors Help Community and featured in the Google Product Experts Directory. Explore his blog to learn advanced formulas, automation tips, and problem-solving techniques to elevate your spreadsheet skills.

Calculate Trip Days by Month (Start, End, and Full Days) in Google Sheets

If you're managing business travel in Google Sheets, you may need to calculate how...

Mode of Comma-Separated Numbers in Excel (Dynamic Array)

There is no dedicated function in Excel to directly find the mode of comma-separated...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

More like this

Calculate Trip Days by Month (Start, End, and Full Days) in Google Sheets

If you're managing business travel in Google Sheets, you may need to calculate how...

How to Find Mode of Comma-Separated Numbers in Google Sheets

Working with comma-separated numbers inside a single cell is a common scenario in Google...

How to Count Merged Cells in Google Sheets (and Get Their Size)

Sometimes, you may have blocks of merged cells in a column or row. But...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.