Calculate Travel and Service Time as Decimal Hours in Excel
Question details
Calculate travel, service, and total work time as decimal hours, including periods that cross midnight and rows with missing inputs.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A timesheet records outbound travel, service, return travel, and breaks in separate cells and needs correct row and column totals.
- Observed behavior
- Simple time subtraction can produce incorrect results across midnight, and formulas may not handle travel-only or incomplete entries as intended.
Enter actual Excel time values, not text, in B14:E14. Use B and C for outbound travel, C and D for service, D and E for return travel, and F for an optional break entered as a time duration, such as 0:30.
Calculate Decimal Hours with Midnight-Aware Formulas
Use these formulas when each individual travel or service period is shorter than 24 hours and a travel-only row may contain just one complete travel pair.
MOD handles a period that crosses midnight. Identical start and end times are treated as zero hours, not 24 hours; use dates as well as times if a period can last 24 hours or more.
Leave F14 blank if there is no break, or enter the break as a time duration. Ensure the break does not exceed the service period.
In G14, enter =IF(OR(COUNT(B14:E14)=0,AND(COUNT(B14:C14)<>0,COUNT(B14:C14)<>2),AND(COUNT(D14:E14)<>0,COUNT(D14:E14)<>2)),"",24*(IF(COUNT(B14:C14)=2,MOD(C14-B14,1),0)+IF(COUNT(D14:E14)=2,MOD(E14-D14,1),0))). A complete outbound or return pair can calculate on its own; an incomplete pair leaves G14 blank.
In H14, enter =IF(COUNT(C14:D14)<>2,"",24*(MOD(D14-C14,1)-IF(ISNUMBER(F14),F14,0))). This calculates service between C14 and D14, less any numeric break duration in F14.
In I14, enter =IF(COUNT(G14:H14)=0,"",SUM(G14:H14)). This adds available results, including a travel-only result. Check the input cells before using the total: if a travel pair is incomplete but service is calculated, I14 will show only the available service hours.
Select G14:I14 and choose Home > Number > Number. Copy the formulas down the timesheet, then use a formula such as =SUM(I14:I17) in the total row.

Calculate Travel and Service Hours in WPS Spreadsheet
Use the same midnight-aware formulas in WPS Spreadsheet to calculate travel, service, and total hours, then save the timesheet in an Excel-compatible format.
- 1. Open the timesheet: Open WPS Spreadsheet and use Open to select your Excel timesheet, or create a blank workbook.
- 2. Enter time values: Enter outbound travel, service, and return travel times in B14:E14, and enter an optional break duration in F14.
- 3. Add the calculations: Paste the travel formula into G14, the service formula into H14, and the total formula into I14, as shown above.
- 4. Format and total the results: Select G14:I14 and choose a Number format. Copy the formulas down and use SUM in the total row; check incomplete entries before relying on each row total.
- 5. Save the workbook: Use File > Save As and choose Excel Workbook (.xlsx) if you need to share the timesheet with Excel users.

Frequently Asked Questions
How does the formula handle a trip that crosses midnight?
MOD(end-start,1) returns the elapsed fraction of a day for a period shorter than 24 hours. Multiplying by 24 converts it to decimal hours.
Can I calculate a travel-only row?
Yes. Enter a complete outbound pair in B14:C14 or return pair in D14:E14. The travel formula calculates the available pair, and the total formula adds the available result.
Why is my row total showing only service hours?
If a travel pair is incomplete, G14 is blank, but H14 may still calculate when C14 and D14 are present. Check B14:E14 and complete or correct the travel entries before relying on I14.
How do I show a decimal-hour total as hours and minutes?
In another cell, divide the decimal-hour total by 24, for example =I18/24. Apply the custom number format [h]:mm to that cell so totals over 24 hours display correctly.
What should I do if a period lasts 24 hours or more?
Enter both dates and times for the start and end, then subtract the start date-time from the end date-time and multiply by 24. The MOD formulas above cannot distinguish a full day from zero elapsed time.




