This is an interesting logical challenge. I broke it down into a couple of parts:
In cell A1 is the input date.
In cell A2 is the 25th of the month from after today.
(Note that you can put TODAY() instead of the "A1" there, I made it a reference so I could manually enter things in A1 for testing).
Note that DATE(2020, 13, 25) is resolved as "Jan 25, 2020" so that will handle rolling over into the next year for us automatically.
In cell A3 we have a weekend handler
This will resolve as 1 if A2 is a Saturday or a 2 if A2 is a Sunday.
In cell A4 we have a holiday handler
This will return 1 in two cases:
1) A2 itself is a holiday.
2) If A2 - A3 (eg, the presumptive next payday) is a holiday. (To handle a case where the 25th is on the weekend but the 23rd or 24th, for whatever reason, is a bank holiday and we need to pull payday forward to Thursday).
Note this is assuming a manually entered range of Bank Holidays in cells D1:D10, with each holiday given it's own cell. If you already have that somewhere else in your spreadsheet you can point there instead.
In cell A5 is the date of the next payday
Note that because of the choice in A2 to check for dates greater than the 25th, this will tell you that "today" is the next payday when A1 =August 25th, 2020.
If you wanted it to instead say that the next payday is September 25th, you'd put a ">=" instead of a ">" in the "DAY()>A1" term in cell A2.
Finally in Cell A6 is The Output, "Days until Next Payday"
If you dropped the "A1=TODAY()" cell usage you can just make it "=A5-TODAY()" instead
Bookmarks