Excel Formula to Calculate Timesheet Hours With a One-Hour Minimum
Question details
Calculate timesheet hours with a minimum of one hour while returning zero for incomplete entries and handling shifts that cross midnight.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A timesheet has a start time in D5 and an end time in E5, with the calculated hours displayed in F5.
- Observed behavior
- The desired formula returns decimal hours, applies a one-hour minimum to completed entries, and returns zero if either time is blank.
Enter valid time values in D5 and E5, and reserve F5 for the result. This formula assumes time-only entries and shifts shorter than 24 hours.
Calculate hours with a one-hour minimum in Excel
Use this formula to calculate decimal hours, including overnight shifts, while leaving incomplete rows at zero.
Open your timesheet in Excel and select F5, where the calculated hours should appear.
In F5, enter =IF(OR(E5="",D5=""),0,IF(E5<D5,MAX((E5-D5)*24+24,1),MAX((E5-D5)*24,1))) and press Enter.
Select F5 and choose Home > Number > Number so the result displays as decimal hours rather than a time.
Drag the fill handle from F5 down the column to copy the formula to additional timesheet rows.

Calculate minimum timesheet hours in WPS Spreadsheet
Use the same formula in WPS Spreadsheet to calculate decimal hours, account for overnight shifts, and apply a one-hour minimum.
- 1. Open the timesheet: Open your Excel workbook in WPS Spreadsheet and locate the start and end time columns.
- 2. Enter the times: Enter the start time in D5 and the end time in E5.
- 3. Add the formula: Select F5, enter =IF(OR(E5="",D5=""),0,IF(E5<D5,MAX((E5-D5)*24+24,1),MAX((E5-D5)*24,1))) and press Enter.
- 4. Format and copy the result: Use the Home tab's number-format controls to display F5 as a number, then drag its fill handle down to apply the formula to other rows.

Frequently Asked Questions
What does the formula return if a time is missing?
If D5 or E5 is blank, the formula in F5 returns 0 instead of applying the one-hour minimum.
How does the formula handle a shift that ends after midnight?
When E5 is earlier than D5, the formula treats E5 as a time on the following day and adds 24 hours to the difference.
Why does a 30-minute shift show as one hour?
The MAX function sets the minimum result for completed entries to 1. Longer shifts return their actual duration in decimal hours.
Can this formula calculate a full 24-hour shift?
No. Equal start and end times return one hour. Use start and end dates as well as times if shifts can last 24 hours or longer.
Why does the result look like a time instead of a number?
Select the result cell and choose Home > Number > Number in Excel. The formula returns decimal hours, so it should not use a time format.




