How to Create an Excel IF Formula for ON TIME or LATE Based on Time Difference
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).

- 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.
Ensure both your scheduled time and actual time columns are formatted as 'Time' in Excel before applying the calculation formulas.
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.
Click on the cell where you want the status label to appear, for example, cell D3.
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.
Press Enter to execute the formula and check the result for the first row.
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 a Basic IF Formula (For Same-Day Times Only)
A simpler formula approach if all your scheduled and actual times strictly fall within the same calendar day.
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. Open your time tracking file: Launch WPS Spreadsheet and open your existing time tracking or attendance document.
- 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. Use Smart Fill: Double-click the fill handle on the cell's bottom right to instantly apply the calculation to all rows.
- 4. Save and share seamlessly: Save your document in .xlsx format to ensure seamless sharing and compatibility with Microsoft Office users.

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.




