+ Reply to Thread
Results 1 to 14 of 14

Subtracting business days from end of month

  1. #1
    Registered User
    Join Date
    10-19-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    18

    Subtracting business days from end of month

    Hi - I am trying to come up with a formula that will calculate the estimated date for when my projected funding will run out. I have already come up with the number that needs to be subtracted form the end of a particular month, but I can not figure out how to subtract the amount of business days from the end date. I have attached the spreadsheet as an example, does anyone know of a simple formula to solve this issue?

    Thanks,
    GRDecker

    Sample 1 Date.xlsx

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,737

    Re: Subtracting business days from end of month

    does this help at all
    http://www.ozgrid.com/forum/showthread.php?t=80985

  3. #3
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,737

    Re: Subtracting business days from end of month

    this should do it
    =IF(WEEKDAY(C2,2)=7,C2-2,IF(WEEKDAY(C2,2)=6,C2-1,C2))
    will not include holidays
    Attached Files Attached Files
    Last edited by etaf; 02-27-2013 at 10:55 AM.

  4. #4
    Registered User
    Join Date
    10-19-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Subtracting business days from end of month

    Quote Originally Posted by etaf View Post
    this should do it
    =IF(WEEKDAY(C2,2)=7,C2-2,IF(WEEKDAY(C2,2)=6,C2-1,C2))
    will not include holidays
    This formula returned a date of 3/29/2013. What I need to figure out is what the last possible work day in the month of March, when I know that my funds will run out 6.32 days before the last possible workday. Cell B2 has the 6.32 figure.

  5. #5
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,737

    Re: Subtracting business days from end of month

    so on your example , end of month is a Sunday 31/3
    last business day that month is Friday
    so if we go back by the value in B2 - in this case 6.32
    will always go back to a business day
    =IF(WEEKDAY(C2,2)=7,C2-2-B2,IF(WEEKDAY(C2,2)=6,C2-1-B2,C2-B2))

    but these dates assume midnight and I notice you are using a fraction of the day - so did you want to calculate based on business hours at all

    if the amount to go back varies - and falls on a weekend - do you then want to also go back to the previous business day ?

    so calculating from midnight 6.32 days - goes back to a friday - BUT
    from 17:00 - goes back to saturday

  6. #6
    Registered User
    Join Date
    10-19-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Subtracting business days from end of month

    Hi - Thanks for the details. There is no need to go back to the hour, only a business day. So I will probably use the round function on my previous formula that gets me to 6.32. So lets just use whole numbers for this example.

  7. #7
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,737

    Re: Subtracting business days from end of month

    so this should work
    =IF(WEEKDAY(C2,2)=7,C2-2-B2,IF(WEEKDAY(C2,2)=6,C2-1-B2,C2-B2))

    and what happens if that falls on a saturday or sunday ?

  8. #8
    Registered User
    Join Date
    10-19-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Subtracting business days from end of month

    If the date falls on a Saturday, then I would need to move it back to the Friday.

  9. #9
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,737

    Re: Subtracting business days from end of month

    so that would be reasonably easy by another nested IF testing the days
    =IF(WEEKDAY(C19,2)=7,IF(WEEKDAY(C19-2-B19,2)=7,C19-4-B19,IF(WEEKDAY(C19-2-B19,2)=6,

    if the weekday is a sunday - then take the 2 days back to friday and then the 6 days back
    is the result of C19-2-B19 a weekend - if so go back another day or 2
    had a quick play and lost the nested IFs - need to leave for a while now
    this is wrong as I'm missing some of the false startments in the nested ifs
    =IF(WEEKDAY(C19,2)=7,IF(WEEKDAY(C19-2-B19,2)=7,C19-4-B19,IF(WEEKDAY(C19-2-B19,2)=6,C19-3-B19,IF(WEEKDAY(C19,2)=6,IF(WEEKDAY(C19-1-B19,2)=7,C19-3-B19,IF(WEEKDAY(C19-1-B19,2)=6,C19-2-B19,C19-B19))))))

    ughhhhh

  10. #10
    Registered User
    Join Date
    10-19-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Subtracting business days from end of month

    Dang - that is one hell of a formula. I appreciate your help on this. I can't believe this would be that complex just to figure what seems such a simple question.

  11. #11
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,737

    Re: Subtracting business days from end of month

    yep, i have stopped for the night working on it , as i lost the plot - so will look again tomorrow - i have simplified the formula a little using AND/OR

    there maybe a simpler way - just the way my mind was working
    test to see if the day is a Sunday and if the result is a sunday
    then if a combination of Sunday/saturday
    then if a saturday and result is a saturday - but sleeping on it may come up with a much better solution
    another none working formula
    =IF(AND(WEEKDAY(C19,2)=7,WEEKDAY(C19-2-B19,2)=7),C19-4-B19,IF(OR(AND(WEEKDAY(C19,2)=7,WEEKDAY(C19-2-B19,2)=6),AND(WEEKDAY(C19,2)=6,WEEKDAY(C19-2-B19,2)=7), AND(WEEKDAY(C19,2)=7,WEEKDAY(C19-1-B19,2)=7),AND(WEEKDAY(C19,2)=6,WEEKDAY(C19-1-B19,2)=6)),C19-3-B19,IF(AND(WEEKDAY(C19,2)=6,WEEKDAY(C19-1-B19,2)=6),C19-1-B19,IF(WEEKDAY(C19-2-B19)=7,C19-2-B19,IF(WEEKDAY(C19-1-B19,2)=6,C19-1-B19,C19-B19)))))

  12. #12
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Subtracting business days from end of month

    It's not clear to me what the result should be - perhaps you can indicate the required results for a number of different values?

    To get the last working day of the month given last day of the month in C2 you can use WORKDAY function, i.e.

    =WORKDAY(C2+1,-1)

    so if it's just a case of getting 6.32 days before that formula can be

    =WORKDAY(C2+1,-1)-B2

    or 6.32 workdays before that

    =WORKDAY(C2+1,-1-B2)

    If it's the former and you want it to default to the previous workday if it's a weekend then that would be

    =WORKDAY(WORKDAY(C2+1,-1)-B2+1,-1)

    I assume the formula in red will do what you want
    Last edited by daddylonglegs; 02-27-2013 at 04:20 PM.
    Audere est facere

  13. #13
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,737

    Re: Subtracting business days from end of month

    much simpler - dah!!!
    I have just worked through all possible variations of days starting and stopping and the required result and that works
    =WORKDAY(WORKDAY(C2+1,-1)-B2+1,-1)
    perfect on my example await OP reply - but works on my sheet , been at this a few hours myself

    thanks daddylonglegs i learnt a new function I was not aware of

  14. #14
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,737

    Re: Subtracting business days from end of month

    much simpler - dah!!!
    I have just worked through all possible variations of days starting and stopping and the required result and that works
    =WORKDAY(WORKDAY(C2+1,-1)-B2+1,-1)
    perfect on my example await OP reply - but works on my sheet , been at this a few hours myself

    thanks daddylonglegs i learnt a new function I was not aware of, or at least how to use it properly

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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