Hello,
I have been trying to write a formula that calculates the number of days until the next pay day. If the next payday is a Saturday or Sunday, use the nearest Friday for the end date.
I have all the pieces but cannot stitch them all together and have clearly overcomplicated this and exceeded my comfort level.
Here is what I have been working through
Start with which month I should be referencing
=IF(DAY(TODAY())<26,"This Month","Next Month")
Work Through the This Month Scenario
1. Calculate the days untill the 26th of This Month
=IF(DAY(TODAY())<26,DAYS(DATE(YEAR(TODAY()),MONTH(TODAY()),26),TODAY()),"Next Month")
2. Check if the 26th is a weekend
=IF(WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()),26),2)>5,"Weekend, Find Nearest Friday","Weekday, Use the 26th")
3. Find Nearest Friday
=DATE(YEAR(TODAY()),MONTH(TODAY()),26-MOD(WEEKDAY(A1)-6,7))
4. Integrate 2 and 3
=IF(WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()),26),2)>5,DATE(YEAR(TODAY()),MONTH(TODAY()),26-MOD(WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()),26)-6,7)),DATE(YEAR(TODAY()),MONTH(TODAY()),26))
5 Integrate 1 and 4
=IF(DAY(TODAY())<26,DAYS(F(WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()),26),2)>5,DATE(YEAR(TODAY()),MONTH(TODAY()),26-MOD(WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()),26)-6,7)),DATE(YEAR(TODAY()),MONTH(TODAY()),26)),TODAY()),"Next Month")
6. Now Move To Next Month Scenario, Add +1 To the Month from 4
=IF(WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()+1),26),2)>5,DATE(YEAR(TODAY()),MONTH(TODAY()+1),26-MOD(WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()+1),26)-6,7)),DATE(YEAR(TODAY()),MONTH(TODAY()),26))
7. Integrate 6 and 5
Final Formula is this correct? If it is i am expecting it to fail come december 2022 :-(
=IF(DAY(TODAY())<26,DAYS(IF(WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()),26),2)>5,DATE(YEAR(TODAY()),MONTH(TODAY()),26-MOD(WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()),26))-6,7)),DATE(YEAR(TODAY()),MONTH(TODAY()),26)),TODAY()),DAYS(IF(WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()+1),26),2)>5,DATE(YEAR(TODAY()),MONTH(TODAY()+1),26-MOD(WEEKDAY(DATE(YEAR(TODAY()),MONTH(TODAY()+1),26))-6,7)),DATE(YEAR(TODAY()),MONTH(TODAY()+1),26)),TODAY()))
Bookmarks