Certainly! Based on the payment history and the behavior you've described, we can adjust the formula to account for this specific payment schedule.
Understanding the Payment Schedule
Scheduled Pull Date : The payment is initially scheduled for the 29th of each month.
Adjustment for Unavailable Dates :
If the 29th is on a weekend or holiday , the scheduled pull date moves to the next available business day .
Actual Pull Date in Bank Account :
Typically : The actual pull occurs one day after the scheduled pull date.
If the actual pull date falls on a weekend or holiday , it moves to the next available business day .
This behavior can cause:
Skipping a month : If the adjusted scheduled date moves into the next month, the payment for the current month is skipped.
Two payments in a month : If the adjusted scheduled date for the previous month moves into the next month, there will be two payments in that month.
Goal
Create a formula that, for any given date range, calculates the actual pull dates based on the above rules.
Steps to Adjust the Formula
Generate Scheduled Dates :
Start with the 29th day of each month within the desired date range.
Adjust Scheduled Dates for Weekends/Holidays :
If the scheduled date falls on a weekend or holiday, move it to the next available business day.
Calculate Actual Pull Dates :
Add one day to the (adjusted) scheduled date.
If this date falls on a weekend or holiday, move it to the next available business day.
Account for Month Skipping :
Note that if the scheduled date moves into the next month, the payment may skip the current month.
Implementing the Formula in Excel
Below is a step-by-step guide to implementing this in Excel. We'll use helper columns to make the formula easier to understand.
Step 1: List of Months
In Column A , list the months for which you want to calculate the payment dates.
Use the first day of each month for simplicity.
For example:
A2: 01/04/2023
A3: 01/05/2023
A4: 01/06/2023
And so on.
Step 2: Calculate the Initial Scheduled Date
In Column B , calculate the initial scheduled date (29th of each month).
B2: =DATE(YEAR(A2), MONTH(A2), 29)
Step 3: Adjust Scheduled Date for Weekends/Holidays
We need to adjust the scheduled date if it falls on a weekend or holiday.
Weekends : Saturday and Sunday.
Holidays : You can create a list of holidays in a range (e.g., Holidays named range) if needed.
Formula in Column C (Adjusted Scheduled Date):
Assuming no holidays for simplicity (or you can add them to the formula later):
Step 4: Calculate the Tentative Actual Pull Date
In Column D , calculate the tentative actual pull date by adding one day to the adjusted scheduled date.
Step 5: Adjust Actual Pull Date for Weekends/Holidays
In Column E , adjust the actual pull date if it falls on a weekend or holiday.
Formula in Column E (Final Actual Pull Date):
E2:
excel Copy code
=IF(WEEKDAY(D2, 2) < 6, D2, WORKDAY(D2 - 1, 1))
Again, include holidays in WORKDAY if necessary.
Step 6: Handle Month Skipping
To identify if a payment has moved to the next month, we can compare the month of the adjusted scheduled date with the original month.
In Column F , check if the adjusted scheduled date is in the same month.
Filter or mark payments where this is FALSE to understand skipped months.
Complete Example
Assuming no holidays:
A (Month) B (Scheduled Date) C (Adjusted Scheduled Date) D (Tentative Actual Pull Date) E (Final Actual Pull Date) F (Same Month?) 01/04/2023 =DATE(YEAR(A2),MONTH(A2),29)See formula above =C2+1See formula above =MONTH(C2)=MONTH(A2)01/05/2023 ...
Sample Calculations
Let's compute some of the dates using the above formulas.
April 2023
A2 : 01/04/2023
B2 : =DATE(2023,4,29) ⇒ 29/04/2023
C2 :
WEEKDAY(29/04/2023,2) ⇒ 6 (Saturday)
Since it's not a weekday, adjust:
WORKDAY(29/04/2023 - 1, 1) ⇒ WORKDAY(28/04/2023, 1) ⇒ 01/05/2023 (assuming no holidays)
C2 : 01/05/2023
D2 : 01/05/2023 + 1 ⇒ 02/05/2023
E2 :
WEEKDAY(02/05/2023,2) ⇒ 2 (Tuesday)
It's a weekday, so E2 : 02/05/2023
F2 :
MONTH(01/05/2023) = MONTH(01/04/2023) ⇒ 5 = 4 ⇒ FALSE (Payment moved to the next month)
May 2023
A3 : 01/05/2023
B3 : =DATE(2023,5,29) ⇒ 29/05/2023
C3 :
WEEKDAY(29/05/2023,2) ⇒ Let's say it's 1 (Monday)
It's a weekday, so C3 : 29/05/2023
D3 : 29/05/2023 + 1 ⇒ 30/05/2023
E3 :
WEEKDAY(30/05/2023,2) ⇒ 2 (Tuesday)
It's a weekday, so E3 : 30/05/2023
F3 :
MONTH(29/05/2023) = MONTH(01/05/2023) ⇒ 5 = 5 ⇒ TRUE
So, for May 2023, the payment would pull on 30/05/2023.
This aligns with your described behavior.
Handling Weekends and Holidays
To make the formula more robust, especially regarding holidays:
Create a Named Range for Holidays :
List all holidays in a column, and name the range Holidays.
Adjust the WORKDAY Function :
Include the Holidays range in both adjustments:
For adjusted scheduled date:
excel Copy code
=IF(WEEKDAY(B2, 2) < 6, B2, WORKDAY(B2 - 1, 1, Holidays))
For final actual pull date:
excel Copy code
=IF(WEEKDAY(D2, 2) < 6, D2, WORKDAY(D2 - 1, 1, Holidays))
Summary
Adjusted Scheduled Date (C2):
excel Copy code
=IF(WEEKDAY(B2, 2) < 6, B2, WORKDAY(B2 - 1, 1, Holidays))
Final Actual Pull Date (E2):
excel Copy code
=IF(WEEKDAY(D2, 2) < 6, D2, WORKDAY(D2 - 1, 1, Holidays))
Check for Month Skipping (F2):
excel Copy code
=MONTH(C2) = MONTH(A2)
Implementing in Other Systems
If you are not using Excel or prefer to have a single formula without helper columns, you can nest the functions:
excel Copy code
=IF(WEEKDAY(
IF(WEEKDAY(DATE(YEAR(A2), MONTH(A2), 29), 2) < 6,
DATE(YEAR(A2), MONTH(A2), 29),
WORKDAY(DATE(YEAR(A2), MONTH(A2), 29) - 1, 1, Holidays)
) + 1, 2) < 6,
IF(WEEKDAY(DATE(YEAR(A2), MONTH(A2), 29), 2) < 6,
DATE(YEAR(A2), MONTH(A2), 29),
WORKDAY(DATE(YEAR(A2), MONTH(A2), 29) - 1, 1, Holidays)
) + 1,
WORKDAY(
IF(WEEKDAY(DATE(YEAR(A2), MONTH(A2), 29), 2) < 6,
DATE(YEAR(A2), MONTH(A2), 29),
WORKDAY(DATE(YEAR(A2), MONTH(A2), 29) - 1, 1, Holidays)
) + 1 - 1, 1, Holidays
)
)
However, for clarity and maintainability, using helper columns is recommended.
Conclusion
By following these steps and using the adjusted formula, you should be able to calculate the actual payment dates that account for weekends, holidays, and the specific behavior of your automatic payment system.
If you have any questions or need further assistance with implementing this formula, feel free to ask!