How to Create an Excel Timesheet Formula Subtracting an Optional Unpaid Break
Question details
The user needs an Excel formula to calculate total worked hours that only subtracts an unpaid break when both break start and end times are provided, preventing the total from incorrectly showing zero if the break cells are left blank.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating total work hours on a timesheet where employees may or may not take an unpaid break.
- Observed behavior
- When unpaid break cells are left blank, some basic formulas result in zero total hours or trigger errors instead of calculating the continuous worked hours.
Ensure your time-in and time-out data cells are properly formatted as "Time" in your spreadsheet, and that your target total hours cell is formatted as "General" or "Number".
Calculate Hours with an IF, OR, and MOD Formula
This formula explicitly checks if either break cell is empty before deciding whether to subtract break time, ensuring continuous hours are calculated accurately.
Using the MOD function helps handle shifts that cross midnight, while the IF and OR functions ensure breaks are only subtracted when both the break start and end times are recorded in the timesheet.
Click on the cell where you want the total calculated hours to be displayed for that specific row.
Type the following formula into the formula bar: =IF(OR([@[Unpaid Time Start]]="",[@[Unpaid Time End]]=""),MOD([@[Time Out]]-[@[Time In]],1)*24,MOD([@[Time Out]]-[@[Time In]]-[@[Unpaid Time End]]+[@[Unpaid Time Start]],1)*24)
Ensure the column names in the formula (like [@[Time In]]) exactly match the headers in your Excel table. Press Enter to apply.
Right-click the result cell, select "Format Cells," and choose "General" or "Number" to display the hours correctly as a decimal (e.g., 8.5).

Calculate Hours Using a Direct MOD Formula
A simpler formula that calculates the difference directly, ideal if blank cells are cleanly treated as zeros by your spreadsheet version.
Use WPS Spreadsheet for Timesheet Calculations
WPS Spreadsheet offers full support for advanced time calculations, including IF, OR, and MOD functions. It is a powerful, free tool to manage your timesheets and payroll tracking effortlessly.
- 1. Open your timesheet: Launch WPS Spreadsheet and open your existing timesheet file.
- 2. Apply the formula: Click on the total hours cell and paste the provided IF/OR timesheet formula.
- 3. Format the cells: Right-click the cell, select "Format Cells," and navigate to the Number tab to set the result to "Number" with 2 decimal places.

Frequently Asked Questions
Why does my timesheet formula show a #VALUE! error?
A #VALUE! error occurs when text (like "N/A" or "No Break") is entered into cells expected to contain time or numbers. Ensure your time-in and time-out cells only contain valid time formats or remain completely blank.
How do I format the total hours to show decimals instead of time?
Right-click the cell containing your formula, select "Format Cells," navigate to the "Number" tab, and select "General" or "Number". Because the formula multiplies the result by 24, this converts the internal time serial number into standard decimal hours (e.g., 8.5 hours).
Does this formula work for overnight shifts crossing midnight?
Yes, using the MOD function (e.g., MOD(Time Out - Time In, 1)) ensures that shifts crossing midnight are calculated correctly by finding the remainder when divided by 1.
What happens if only one break time (start or end) is entered?
By using the IF(OR(Start="", End="")) logic, the formula will ignore the break calculation entirely if either the start or end time is missing, preventing inaccurate time deductions.




