logo
search
Function Problems

How to Return a Value Based on a 30-Minute Time Window in Spreadsheets

Chanuka GeekiyanageChanuka Geekiyanage Sep 25, 2026 869 views

Question details

The user needs a formula to compare a check-in date and time against an expected delivery date and time, and return a specific load number if they fall within 30 minutes of each other.

How to Return a Load Number When Check-In Is Within a 30-Minute Window
Product
WPS Spreadsheet / Microsoft Excel
Device & OS
not provided
Scenario
Tracking logistics by comparing actual check-in times with scheduled delivery times to dynamically pull valid load numbers from a dataset.
Observed behavior
The formula needs to output the load number from column B when the dates match and the time difference is less than or equal to 30 minutes, otherwise it should return a blank cell.
Before you start

Ensure that your date and time columns are properly formatted as numeric dates and times (not text strings) so that mathematical time operations function correctly.

Solution 1Recommended

Use a Combined IF and ABS Formula to Compare the Time Window

Calculate the exact time difference using a combination of logical and mathematical functions to evaluate if the check-in time falls within 30 minutes of the expected delivery time.

To check if two times are within a specific window, you can subtract one from the other. By using the ABS (Absolute) function, you can account for check-ins that are either 30 minutes early or 30 minutes late.

The INT function is used to extract the date portion from a combined datetime cell, while the MOD function extracts just the time.

1
Identify the reference cells

Locate the check-in date (e.g., AH2), check-in time (e.g., AI2), expected delivery date and time (e.g., AK2), and the load number (e.g., B2).

2
Extract the date portion for comparison

Use the INT(AK2) function to extract just the date from the expected delivery date/time cell to compare it with the check-in date in AH2.

3
Extract and compare the time portion

Use MOD(AK2, 1) to get the time from the expected delivery cell. Then, calculate the absolute difference using ABS(AI2 - MOD(AK2, 1)) <= TIME(0,30,0) to ensure the difference is exactly 30 minutes or less.

4
Combine into an IF statement

Select the cell where you want the load number to appear and enter the full formula: =IF(AND(AH2=INT(AK2),ABS(AI2-MOD(AK2,1))<=TIME(0,30,0)),B2,""). Press Enter.

5
Apply to the rest of the column

Click the small square at the bottom-right corner of the cell containing your new formula and drag it down to apply the logic to all rows in your logistics dataset.

Use a Combined IF and ABS Formula to Compare the Time Window
Understanding the TIME function: The TIME(0,30,0) syntax represents 0 hours, 30 minutes, and 0 seconds. It seamlessly translates minutes into the fractional values spreadsheets use for time calculation.
Advanced Spreadsheet Formulas Made Easy

Easily Manage Logistics and Time Calculations with WPS Spreadsheet

WPS Spreadsheet provides powerful data processing capabilities, including advanced date, time, and logical functions, to help you track logistics efficiently and accurately.

  1. 1. Download and install: Get WPS Office from the official website and open your logistics spreadsheet.
  2. 2. Enter your data: Ensure your date, time, and load number columns are clearly defined and appropriately organized.
  3. 3. Format cells: Select the time and date cells, right-click and choose 'Format Cells' to apply the correct Date or Time formatting.
  4. 4. Apply the time window formula: Paste the =IF(AND(...)) formula into your target column to automatically filter and extract load numbers.
Fully compatible with Microsoft Excel formulas and file formats (.xlsx).Includes hundreds of built-in functions for complex date, time, and logical operations.Lightweight application with high performance even on large datasets.Free to use with a familiar tabbed user interface, requiring zero learning curve.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my formula return an error or unexpected text?

This usually happens if your date or time cells are formatted as text instead of numerical dates and times. Select the cells, go to 'Format Cells', and apply the correct Date and Time formats.

How can I change the time window from 30 minutes to 1 hour?

Simply modify the TIME(0,30,0) portion of the formula to TIME(1,0,0). The TIME function syntax is TIME(hours, minutes, seconds).

What if my check-in date and time are merged into the same cell?

If your check-in date and time are combined in a single cell (e.g., AH2), you can simplify the formula to compare the two datetime values directly using =IF(ABS(AH2-AK2)<=TIME(0,30,0),B2,"").

Does the ABS function matter if the check-in is always late?

The ABS function guarantees the difference is mathematically positive. While you could drop it if check-ins are strictly late (post-delivery time), using ABS creates a robust bidirectional time window that accounts for both early and late arrivals.