Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Excel IF Between Two Numbers or Dates: Formula Guide

· 4 min read · Home Tech

In this article
  1. Formula
  2. Worked Example
  3. How to Use the IF Function with Between
  4. Dealing with Dates
  5. Common Mistakes and Misconceptions
  6. Alternatives to IF with AND
  7. Frequently Asked Questions

This article explains how to use Excel's IF function to check whether a value falls between two numbers or two dates, and what formula to write to return a result like "Yes" or "No". You'll learn the exact syntax, how to handle dates correctly, and common mistakes to avoid.

Formula

The standard formula to test if a value in cell A1 is between two numbers (say, 10 and 20) is:

   =IF(AND(A1>=10, A1<=20), "Yes", "No")

For dates, the same logic applies, but you must enter the dates as date values, not text. For example, to check if a date in A1 falls between January 1, 2025 and December 31, 2025:

   =IF(AND(A1>=DATE(2025,1,1), A1<=DATE(2025,12,31)), "Yes", "No")

Here, AND checks both conditions at once. If both are true, the IF function returns the first value ("Yes"); otherwise it returns the second ("No"). You can replace the text with any value, calculation, or another formula.

Worked Example

Let's use the default values from the calculator above: a start number of 50 and an end number of 100. Suppose cell A1 contains the number 75. The formula would be:

   =IF(AND(A1>=50, A1<=100), "Yes", "No")

Since 75 is greater than or equal to 50 and less than or equal to 100, the result is "Yes". If A1 contained 120, the result would be "No".

How to Use the IF Function with Between

The IF function alone only tests one condition. To test a range, you combine it with the AND function. The structure is:

  1. Start with =IF(.
  2. Add AND( and then the first condition (e.g., A1>=lower).
  3. Add a comma and the second condition (e.g., A1<=upper).
  4. Close the AND with a parenthesis.
  5. Add a comma, then the value if true, another comma, and the value if false.
  6. Close the IF with a parenthesis and press Enter.

You can also use the IFS function for multiple ranges, or the MEDIAN function for a quick check, but IF+AND is the most straightforward for most users.

Dealing with Dates

Dates in Excel are stored as serial numbers, so you can compare them with the same operators. However, you must ensure the dates are actual date values, not text. Use the DATE function to build dates in the formula, or reference cells that contain real dates. For example:

   =IF(AND(A1>=DATE(2025,1,1), A1<=DATE(2025,12,31)), "In range", "Out of range")

If you type "1/1/2025" directly in the formula, Excel might interpret it as text, causing errors. Always use DATE or cell references.

Common Mistakes and Misconceptions

One common mistake is using OR instead of AND. OR returns true if any condition is true, which would always be true for any number (since it's either greater than the lower bound or less than the upper bound). Another mistake is forgetting the equal sign in the conditions, which excludes the boundary values. Also, be careful with the order of arguments: the lower bound must be first, the upper bound second.

Another misconception is that you can use a range like A1:A10 in the AND function. That works only if you want to check if all cells in the range meet the condition, which is different. For a single cell, use a single cell reference.

Alternatives to IF with AND

If you only need to return a TRUE/FALSE value, you can skip IF entirely and just use:

   =AND(A1>=10, A1<=20)

This returns TRUE if in range, FALSE otherwise. For more complex logic, consider the IFS function for multiple ranges, or the FILTER function in Excel 365 to extract rows that fall between two dates.

Frequently Asked Questions

How do I check if a date is between two dates in Excel?

Use the same IF+AND formula, but replace the numbers with date references or DATE functions. For example, =IF(AND(A1>=DATE(2025,1,1), A1<=DATE(2025,12,31)), "Yes", "No").

Can I use the IF function with text like "In range" and "Out of range"?

Yes, just replace "Yes" and "No" with any text you want, enclosed in double quotes.

What if I want to include the boundary numbers?

Use >= and <= instead of > and <. That includes the lower and upper bounds.

How do I check if a date is within the current month?

Use the EOMONTH function to get the first and last day of the current month, then compare. For example: =IF(AND(A1>=EOMONTH(TODAY(),-1)+1, A1<=EOMONTH(TODAY(),0)), "Yes", "No").

Why does my formula return a #VALUE! error?

This usually happens when the cell contains text that Excel can't interpret as a number or date. Check that the cell values are numeric or actual dates, not text.

Can I use this for time values?

Yes, time values are also numbers in Excel. The same formula works with times, as long as they are entered as time values (e.g., 9:00 AM).