+ Reply to Thread
Results 1 to 5 of 5

Days Until Next Pay Day Each Month (26th) , If 26th is weekend rollback to nearest Friday

  1. #1
    Registered User
    Join Date
    03-01-2022
    Location
    Cork, Ireland
    MS-Off Ver
    O365
    Posts
    2

    Days Until Next Pay Day Each Month (26th) , If 26th is weekend rollback to nearest Friday

    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()))
    Last edited by MinistryCork; 03-01-2022 at 10:00 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,428

    Re: Days Until Next Pay Day Each Month (26th) , If 26th is weekend rollback to nearest Fri

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,428

    Re: Days Until Next Pay Day Each Month (26th) , If 26th is weekend rollback to nearest Fri

    Try this:

    =LET(pd,DATE(YEAR(TODAY()),MONTH(TODAY()),26),IF(DAY(TODAY())<26,pd-LOOKUP(WEEKDAY(pd,2),{0,6,7},{0,1,2}),EDATE(pd,1)-LOOKUP(WEEKDAY(EDATE(pd,1),2),{0,6,7},{0,1,2})))

    or this:

    =LET(pd,DATE(YEAR(TODAY()),MONTH(TODAY()),26),pdn,EDATE(pd,1),IF(DAY(TODAY())<26,pd-LOOKUP(WEEKDAY(pd,2),{0,6,7},{0,1,2}),pdn-LOOKUP(WEEKDAY(pdn,2),{0,6,7},{0,1,2})))
    Last edited by AliGW; 03-01-2022 at 10:12 AM.

  4. #4
    Registered User
    Join Date
    03-01-2022
    Location
    Cork, Ireland
    MS-Off Ver
    O365
    Posts
    2

    Re: Days Until Next Pay Day Each Month (26th) , If 26th is weekend rollback to nearest Fri

    Thank You, Admittedly I am not sure how it's working but that looks to return the expected date from which I can calculate the days.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,428

    Re: Days Until Next Pay Day Each Month (26th) , If 26th is weekend rollback to nearest Fri

    It's doing what you described in your opening sentence. If you need it explaining, just ask.

    If you need more help, attach a workbook.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 11
    Last Post: 12-31-2020, 11:00 AM
  2. [SOLVED] Need date to be 20th of month or nearest Friday if 20th is weekend
    By Ochimus in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-02-2016, 03:37 AM
  3. Fill Every 26th Cell With A Number 26 Times
    By Joel Caldwell in forum Excel General
    Replies: 3
    Last Post: 11-10-2014, 03:06 PM
  4. Replies: 3
    Last Post: 10-11-2014, 09:04 PM
  5. [SOLVED] Count number of days between two date where off days are Friday,Sat & Only Friday
    By rollcage7 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 03-15-2014, 07:14 AM
  6. [SOLVED] Count the days excluding Friday in every month using a date range.
    By miss_chloe in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-23-2013, 10:42 AM
  7. Replies: 9
    Last Post: 12-19-2012, 01:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1