How to Find the Last and First Timestamp Around a Shift Change in Excel
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.

- 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.
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.
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.
Select the column containing your machine timestamps and optionally name the range 'Times' using the Name Box in the top-left corner.
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.
In a blank cell, enter the formula =MAXIFS(Times,Times,"<"&F1) and press Enter. This returns the latest time recorded before 6:00 AM.
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.

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. Open your dataset: Launch WPS Spreadsheet and open your machine timestamp log file.
- 2. Enter the formulas: Use the MAXIFS and MINIFS formulas directly in the cells to calculate the shift boundaries.
- 3. Format the results: Right-click the formula result cells, choose 'Format Cells', and apply a Time format to view the extracted timestamps clearly.

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.




