How to Conditionally Format Times Between 8:30 AM and 5:30 PM in Excel
Question details
The user needs to highlight rows in a spreadsheet where a logged call time falls within a specific business hours window (8:30 AM to 5:30 PM).

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Filtering and visually categorizing call logs based on whether the timestamp falls inside or outside standard operational hours.
- Observed behavior
- The goal is to automatically apply a background color or text format to rows matching the specific time conditions using a formula rule.
Verify that your call timestamps are formatted as real Excel time or date-time values, rather than just text strings, by checking if the values align to the right side of the cell by default.
Use the AND and TIME Functions in a New Formatting Rule
Create a custom conditional formatting formula to check if the time in a given cell is both greater than or equal to 8:30 AM and less than or equal to 5:30 PM.
Excel handles time as fractional values of a 24-hour day. By using the TIME(hour, minute, second) function, you can reliably establish boundaries for your conditional formatting without worrying about raw decimal conversions.
Highlight the cells or entire rows you wish to format. For example, select A2:D100 if your time data is in column A starting at row 2.
Navigate to the 'Home' tab on the Excel ribbon, click 'Conditional Formatting', and select 'New Rule'.
In the dialog box, click on 'Use a formula to determine which cells to format'.
In the formula bar, input: =AND($A2>=TIME(8,30,0),$A2<=TIME(17,30,0)). Ensure you adjust '$A2' to match the first cell of your selected time column. The dollar sign locks the column so the entire row gets highlighted.
Click the 'Format' button, choose a background Fill color (like yellow or green), click 'OK', and then 'OK' again to apply the rule.

Clean and Convert Text-Based Time Values
If your conditional formatting rule does not trigger, your time data may be stored as text containing hidden non-printable characters. You must convert these to actual numeric time values.
Highlight Time Ranges Seamlessly with WPS Spreadsheet
WPS Spreadsheet fully supports advanced Excel conditional formatting formulas, including the TIME and AND functions, letting you process complex data logs quickly and accurately.
- 1. Open your data file: Launch WPS Spreadsheet and open the document containing your call logs.
- 2. Highlight the range: Select the rows or cells that need the time-based highlighting.
- 3. Apply the rule: Go to Home > Conditional Formatting > New Rule, choose the formula option, and paste: =AND($A1>=TIME(8,30,0),$A1<=TIME(17,30,0)).
- 4. Pick a color: Click 'Format', choose a fill color, and confirm to instantly visualize your target times.

Frequently Asked Questions
Why is my formula failing if the cell contains both the date and the time?
If a cell contains a full date and time (e.g., '10/25/2023 9:00 AM'), the underlying value is a large number where the fraction represents the time. The standalone TIME function only compares the fraction. To fix this, use the MOD function to extract just the time: =AND(MOD($A1,1)>=TIME(8,30,0), MOD($A1,1)<=TIME(17,30,0)).
How do I format times outside of the 8:30 AM to 5:30 PM window?
To highlight times outside that range, swap the AND function for the OR function and flip the greater/less than operators. Your formula should look like this: =OR($A1<TIME(8,30,0), $A1>TIME(17,30,0)).
How do I ensure the entire row highlights instead of just the cell with the time?
You need to use mixed references in your formula. By placing a dollar sign ($) strictly in front of the column letter (e.g., $A1 instead of A1), you lock the condition to check column A, allowing the formatting rule to spread horizontally across the entire highlighted row.




