Formula Errors

How to Create an Excel IF Formula for ON TIME or LATE Based on Time Difference

Jason MillerJason Miller Nov 4, 2026 869 views

Question details

The user needs an Excel formula to compare scheduled and actual times, categorizing the result as ON TIME (within 1 hour), LATE (over 1 hour), or CANCELLED (if actual time is blank).

How to Use Excel IF Formula to Show ON TIME or LATE Based on Time Difference
Product
Excel
Device & OS
not provided
Scenario
Tracking employee attendance, delivery schedules, or event timings by calculating the difference between scheduled and actual times and assigning a dynamic text status.
Observed behavior
Requires a formula that handles missing data by marking it cancelled, identifies late scenarios based on a specific threshold, and prevents calculation errors when shifts cross midnight.
Before you start

Ensure both your scheduled time and actual time columns are formatted as 'Time' in Excel before applying the calculation formulas.

Solution 1Recommended

Use Nested IF and MOD Functions to Calculate Time Difference

This is the most reliable method as it accurately calculates time differences even if the actual time passes midnight.

Standard time subtraction in Excel can fail and produce errors or negative values when a scheduled time is before midnight (e.g., 11:00 PM) and the actual time is after midnight (e.g., 12:30 AM). Using the MOD function handles this issue seamlessly.

1
Select the status cell

Click on the cell where you want the status label to appear, for example, cell D3.

2
Enter the nested IF and MOD formula

Type the formula: =IF(C3="","CANCELLED",IF(MOD(C3-B3,1)<=TIME(1,0,0),"ON TIME","LATE")). In this formula, B3 is the scheduled time and C3 is the actual time.

3
Apply the calculation

Press Enter to execute the formula and check the result for the first row.

4
Copy the formula to other rows

Click the small square at the bottom right corner of cell D3 and drag it down the column to apply the formula to all remaining records.

Use Nested IF and MOD Functions to Calculate Time Difference
Understanding the Formula: The TIME(1,0,0) function specifies the exact 1-hour threshold (1 hour, 0 minutes, 0 seconds). The MOD(C3-B3,1) calculation prevents negative time errors when crossing midnight by wrapping the decimal value.
Free Microsoft Office alternative

Easily Manage Time Tracking with WPS Spreadsheet

WPS Office provides a highly capable Spreadsheet application that fully supports Excel functions like IF, MOD, and TIME. You can effortlessly track schedules, handle complex time difference calculations, and format large datasets for free.

  1. 1. Open your time tracking file: Launch WPS Spreadsheet and open your existing time tracking or attendance document.
  2. 2. Enter the nested formula: Select your status column and input the =IF(C3="","CANCELLED",IF(MOD(C3-B3,1)<=TIME(1,0,0),"ON TIME","LATE")) formula.
  3. 3. Use Smart Fill: Double-click the fill handle on the cell's bottom right to instantly apply the calculation to all rows.
  4. 4. Save and share seamlessly: Save your document in .xlsx format to ensure seamless sharing and compatibility with Microsoft Office users.
Fully compatible with Microsoft Excel (.xlsx) formats and nested formulasBuilt-in intelligent formula suggestions and auto-completionLightweight, fast, and completely free to useFamiliar user interface requiring zero learning curve
microsoft office alternative - wps office

Frequently Asked Questions

Why does my formula return a #VALUE! error?

This usually occurs if the cells containing the scheduled or actual times are formatted as plain text instead of time, or if they contain hidden spaces. Highlight the columns, right-click, select 'Format Cells', and ensure both are set to 'Time'.

How can I change the late threshold from 1 hour to 30 minutes?

You can easily adjust the TIME function inside the formula. Replace TIME(1,0,0) with TIME(0,30,0) to set the late threshold limit to exactly 30 minutes.

What does the MOD function do in this specific time calculation?

Excel stores dates and times as serial numbers. When an actual time (like 1:00 AM) is smaller than a scheduled time (like 11:00 PM), standard subtraction yields a negative number. Using MOD(actual-scheduled, 1) wraps the negative decimal into a positive time difference, correctly calculating the duration as 2 hours.

How can I add an 'EARLY' status to the formula?

You can add another nested IF statement to check if the actual time is earlier than the scheduled time. For instance, modifying the logic to check if actual time < scheduled time, return 'EARLY', before proceeding to check the ON TIME and LATE conditions.