+ Reply to Thread
Results 1 to 7 of 7

Rounding weekend days to monday

  1. #1
    Registered User
    Join Date
    03-05-2013
    Location
    Boston, USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    Rounding weekend days to monday

    Hi guys. I am trying to calculate some dates for events that have to occur a certain number of days apart from each other. So, if event 1 is 4/17/2014, I would like to calculate a day 84 days before that date. A1 = 4/17/2014. In B1 =A1-84. But I only want to generate values in B1 that are mondays. The 84 day difference should include all days including weekend days, but the resulting date should round to the nearest monday. Is that possible? Another cell I would like to calculate a difference and the resulting date should only be a weekday. Is that possible if only monday's isn't possible. I am stumped.

  2. #2
    Registered User
    Join Date
    03-05-2013
    Location
    Boston, USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Rounding weekend days to monday

    I figured out the equation for the calculating results that are only weekdays :

    =IF(OR(WEEKDAY(M6-84)=2,WEEKDAY(M6-84)=3,WEEKDAY(M6-84)=4,WEEKDAY(M6-84)=5,WEEKDAY(M6-84)=6),M6-84,IF(WEEKDAY(M6-84)=1,M6-83,M6-85))

    Where there is a date in cell M6, however calulating only mondays has me a bit confused.

  3. #3
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Rounding weekend days to monday

    hi ScottLor, maybe:
    =A1-84-WEEKDAY(A1-84,2)+IF(ROUND(WEEKDAY(A1-84,2)/7,0),8,1)

    but DDL would probably come up with something better since he's looking at this thread. i'm assuming Thurs should be brought forward to the next Mon too
    Last edited by benishiryo; 04-17-2013 at 09:34 AM.

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

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

    Re: Rounding weekend days to monday

    When you say "nearest Monday" do you genuinely mean the nearest (or do you always want the Monday before....or perhaps the Monday after?). To get the nearest (e.g. if A1-84 = Thursday it goes back to the Monday 3 days before, if A1-84 = Friday it goes forward to the next Monday) try this formula

    =A1-84+3-WEEKDAY(A1-84+3,3)
    Audere est facere

  5. #5
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Rounding weekend days to monday

    write at B1
    =A1-84-MOD(WEEKDAY(A1-84,3),7)

  6. #6
    Registered User
    Join Date
    03-05-2013
    Location
    Boston, USA
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Rounding weekend days to monday

    Thanks DDL, I did mean the nearest monday (forward from friday and back from thurs). That equation works great. Can you help me understand equation?

    Why did you add the +3 term and what is the [return type] term in weekday that you entered 3 for?

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

    Re: Rounding weekend days to monday

    If you use the formula

    =WEEKDAY(D2,3) when D2 contains a date that gives you zero on a Monday through to 6 on a Sunday so you can use this formula to get the Monday on or before D2

    =D2-WEEKDAY(D2,3)

    In your case we need to use A1-84 in place of D2 so that becomes

    =A1-84-WEEKDAY(A1-84,3)

    but that would always "round" back to the previous Monday, not the nearest, so if we add 3 days in each part that will give the nearest instead, i.e.

    =A1-84+3-WEEKDAY(A1-84+3,3)

    You can apply the formula for any number of days so if you want 50 days before (rounded to nearest Monday) just replace the two 84s with 50s

+ 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