+ Reply to Thread
Results 1 to 8 of 8

Date function arguments

  1. #1
    Registered User
    Join Date
    02-24-2010
    Location
    Augusta, Maine
    MS-Off Ver
    Excel 2007
    Posts
    15

    Date function arguments

    Does anyone know how to setup a function argument for a start and end date that will allow for the calculation of the day of the week.

    For example:
    Start Date = Thursday, April 01, 2010 End Date = (StartDate+30) Saturday, May 01, 2010

    I need the formula to return the value of a WEEKDAY date if the end date falls on a weekend date. I need it to subtract 1 day if the end date is on a Saturday or subtract 2 days if the end date is on a Sunday.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Date function agruments

    Hello KMTrombley,

    This formula assumes the date to check is in cell A1 and the first day of week starts on Sunday.
    =IF(AND(WEEKDAY(A1)>=2,WEEKDAY(A1)<=6), A1, IF(WEEKDAY(A1) = 7,A1-1,A1-2))
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Date function arguments

    Another way, if A1 contains the start date, and this calculates the end date:

    =A1 + 30 + LOOKUP(WEEKDAY(A1 + 30), {1,2,7}, {-2,0,-1})
    Last edited by shg; 02-24-2010 at 08:22 PM.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Date function arguments

    Another way

    =WORKDAY(A1+31,-1)

  5. #5
    Registered User
    Join Date
    02-24-2010
    Location
    Augusta, Maine
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Date function arguments

    Thank you so much for your help.

  6. #6
    Registered User
    Join Date
    02-24-2010
    Location
    Augusta, Maine
    MS-Off Ver
    Excel 2007
    Posts
    15

    Question Re: Date function arguments

    If I use the following formula will it exclude Federal Holidays?

    =WORKDAY(A1+31,1)

    I just discovered that the workdays to be calculated need to exclude weekends and holidays, so if the end date falls on a Satuday it needs to be pushed to Monday; unless Monday is a holiday then it would need to be pushed to Tuesday.

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Date function arguments

    You would add the holiday dates via the optional third parameter, eg:

    =WORKDAY(A1+31,-1,Z1:Z10)

    where Z1:Z10 is range containing public holiday dates - adapt as required.

    (see XL Help files for more info.)

  8. #8
    Registered User
    Join Date
    02-24-2010
    Location
    Augusta, Maine
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: Date function arguments

    This formula needs to account for WEEKDAYS not WORKDAYS will it work the same way?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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