Function Problems

How to Find the Last and First Timestamp Around a Shift Change in Excel

Jason MillerJason Miller Nov 11, 2026 869 views

Question details

The user needs to locate the final machine timestamp right before a shift starts and the first timestamp immediately after the shift begins.

How to Find the Last and First Timestamp Around a Shift Change in Excel
Product
Excel / WPS Spreadsheet
Device & OS
not provided
Scenario
Tracking machine timestamps around specific shift change times (such as 6:00 AM) to analyze production or operation logs.
Observed behavior
Needs to extract specific time values from a dataset based on a threshold time without manually searching through the records.
Before you start

Ensure your timestamp data is formatted correctly as Time or Date/Time values, and that your dataset contains no blank or text-formatted time cells.

Solution 1Recommended

Use MAXIFS and MINIFS Functions to Find Shift Timestamps

Utilize Excel's conditional maximum and minimum functions to accurately extract timestamps before and after a specific shift time.

The MAXIFS function is perfect for finding the latest time before the shift, while MINIFS finds the earliest time after the shift starts. By referencing a specific cell for the shift change time, you can easily update your calculations without rewriting formulas.

1
Define the time range

Select the column containing your machine timestamps and optionally name the range 'Times' using the Name Box in the top-left corner.

2
Set the shift start time

Enter your shift change time (e.g., '6:00 AM') into a reference cell, such as F1. Make sure it is recognized as a time format.

3
Find the last timestamp before the shift

In a blank cell, enter the formula =MAXIFS(Times,Times,"<"&F1) and press Enter. This returns the latest time recorded before 6:00 AM.

4
Find the first timestamp after the shift

In another cell, enter the formula =MINIFS(Times,Times,">="&F1) and press Enter to get the earliest time recorded at or after 6:00 AM.

Use MAXIFS and MINIFS Functions to Find Shift Timestamps
Adding More Criteria: You can add more criteria ranges and criteria to these formulas to filter timestamps by specific machines or dates. For example: =MAXIFS(Times, Times, "<"&F1, MachineColumn, "Machine A").
WPS Spreadsheet

Easily Manage Shift Timestamps with WPS Spreadsheet

WPS Spreadsheet fully supports advanced functions like MAXIFS and MINIFS, allowing you to track and analyze machine timestamps seamlessly. It offers powerful data analysis tools for all your daily needs.

  1. 1. Open your dataset: Launch WPS Spreadsheet and open your machine timestamp log file.
  2. 2. Enter the formulas: Use the MAXIFS and MINIFS formulas directly in the cells to calculate the shift boundaries.
  3. 3. Format the results: Right-click the formula result cells, choose 'Format Cells', and apply a Time format to view the extracted timestamps clearly.
Fully compatible with Microsoft Excel formulas and formats (.xlsx)Supports advanced statistical functions like MAXIFS and MINIFSFree and lightweight alternative for daily data analysisBuilt-in data filtering and conditional formatting tools
microsoft office alternative - wps office

Frequently Asked Questions

Why do my MAXIFS and MINIFS formulas return 0 or an error?

This usually happens if the data range is not formatted as numbers or time values. Ensure your timestamps are recognized as Time formats, not text. Select your data, right-click, select 'Format Cells', and choose 'Time'.

Can I use these functions in older versions of Excel?

MAXIFS and MINIFS are available in Excel 2019, Office 365, and modern versions of WPS Spreadsheet. If you are using an older version, you may need to use an array formula combining MAX/MIN with IF, such as =MAX(IF(Times<F1, Times)).

How do I format the formula result to display as AM/PM?

Select the cell containing your MAXIFS or MINIFS formula, right-click and click 'Format Cells'. Go to the 'Number' tab, select 'Time', and choose the format that includes AM/PM.