Function Problems

How to Return a Value When a Day Falls Between Two Dates in Excel

John WilsonJohn Wilson Nov 11, 2026 869 views

Question details

Create a dynamic Excel formula that identifies whether a recurring payment day falls within a specified date range and returns the appropriate amount.

How to Return a Value When a Day Falls Between Two Dates in Excel
Product
Excel
Device & OS
not provided
Scenario
Automating recurring payment schedules or conditionally calculating values based on whether a specific day of the month is within a predefined upper and lower limit.
Observed behavior
A dynamic logical formula is needed to test target dates against day limits and output a specific numerical value when the condition is met.
Before you start

Ensure your target date cells are formatted correctly as Dates in Excel, and identify the specific lower and upper day limits you want to use for the calculation.

Solution 1Recommended

Use the MEDIAN and DAY Functions (Recommended)

This clever method uses the MEDIAN function to determine if a specific day falls between a lower and upper limit without needing complex nested IF statements.

The MEDIAN function returns the middle number in a set of values. By comparing the target day against the median of the target day, the lower limit, and the upper limit, we can logically deduce if the target day falls within the range.

1
Select the target cell

Click on the cell where you want the returned payment amount to be displayed.

2
Enter the MEDIAN formula

Type the formula: =(DAY(D$1)=MEDIAN(DAY(D$1),20,25))*20000. In this example, D$1 contains the target date, 20 is the lower day limit, 25 is the upper day limit, and 20000 is the return amount.

3
Make the formula dynamic

Replace the hardcoded numbers (20, 25, and 20000) with their respective cell references (e.g., A2, B2, C2) so the formula updates automatically when you change the limits or amount.

4
Apply the calculation

Press Enter. If you have a column of dates, drag the fill handle down to apply the formula to the rest of your dataset.

Use the MEDIAN and DAY Functions (Recommended)
How the Math Works: In Excel, a TRUE logical test equates to 1, and FALSE equates to 0. If the target day is between the limits, the equation evaluates to TRUE (1), which is then multiplied by your payment amount to return the full value.
Advanced Spreadsheet Software

Easily Calculate Date Ranges with WPS Spreadsheet

WPS Spreadsheet fully supports advanced date and logical functions including MEDIAN, DAY, IF, and AND. You can seamlessly execute complex payment tracking, conditional logic, and data analysis using the exact same formulas.

  1. 1. Open your workbook in WPS Spreadsheet: Launch WPS Office and open the file containing your date and payment data.
  2. 2. Select the formula destination: Click the cell where you want the returned value to appear.
  3. 3. Enter the date checking formula: Input your preferred formula, such as =(DAY(D$1)=MEDIAN(DAY(D$1),20,25))*20000.
  4. 4. Press Enter to calculate: Hit Enter. You can then use the drag-fill handle at the bottom right of the cell to copy the formula to other rows.
100% compatible with Microsoft Excel formulas and functionsSupports dynamic array formulas for complex date calculationsFree, lightweight, and fast to load large datasetsFamiliar user interface with no learning curve
microsoft office alternative - wps office

Frequently Asked Questions

Why does the MEDIAN formula multiply by the payment amount?

In Excel, logical statements result in TRUE or FALSE. When used in a math operation, TRUE evaluates to 1 and FALSE to 0. Multiplying the logical test `(DAY(D$1)=MEDIAN(...))` by your amount returns the full amount if the condition is met (1 * amount), and 0 if it is not (0 * amount).

Can I use exact dates instead of just days of the month?

Yes. If you want to check full dates instead of just the day number, simply omit the DAY function and compare the actual date cells directly. For example: `=IF(AND(D1>=Start_Date, D1<=End_Date), Amount, 0)`.

What if my date range crosses into the next month?

If your recurring period spans across the end of a month (for example, from the 25th of one month to the 5th of the next), the standard MEDIAN or AND logic will fail because 5 is not greater than 25. In this scenario, you should use an IF statement with an OR condition, like `=IF(OR(DAY(D1)>=25, DAY(D1)<=5), Amount, 0)`.