+ Reply to Thread
Results 1 to 22 of 22

Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

  1. #1
    Registered User
    Join Date
    08-20-2016
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    18

    Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Hi Guys!

    Small challenge here to test your mad skills.

    I want a formula - doesn't need to be an IF statement - that will output dates and their times (Sundays should be excluded from outputs).
    Please, please see attached.

    Formula should copy to G7 with the result in G7 for highest ratings.
    Thank you all so much.
    Attached Files Attached Files
    Last edited by chilledmalt; 08-21-2016 at 01:40 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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Did you forget the attachment?

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    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
    Registered User
    Join Date
    08-20-2016
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    18

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Thanks, ALiGW done that.

  4. #4
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Thanks. I'm afraid I don't understand what I am looking at! How does the table relate to the times top left? What significance do the table headings have? Which cells do you want the formula to create?

  5. #5
    Registered User
    Join Date
    08-20-2016
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    18

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Which cells do you want the formula to create?
    -The formula should output the same values shown in the cells under the table headings

    How does the table relate to the times top left?
    - B2 & B3 are inputted to the formula. A2 & A3 & B1 offer context for the inputs - you are starting at 8.30 on Mondays and 9.00 on Saturdays. (You do not work on Sundays)

    What significance do the table headings have?
    -They tell what month it is

    Thanks

  6. #6
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    OK. I think I have it. The sample data under the months other than August had me confused for a while!

    In B7 copied across:

    =IF(WEEKDAY(EDATE(B6,0),2)=7,TEXT(EDATE(B6,0)+1,"dd/mm/yyyy"),TEXT(EDATE(B6,0),"dd/mm/yyyy"))&" "&IF(WEEKDAY(EDATE(B6,0),2)=5,TEXT($B$3,"hh:mm"),TEXT($B$2,"hh:mm"))

    In B8 copied across and down:

    =TEXT(B7+LOOKUP((WEEKDAY(B7,2)),{1,2,3,4,5,6,7},{1,1,1,1,1,2,0}),"dd/mm/yyyy")&" "&IF(WEEKDAY(B7+LOOKUP((WEEKDAY(B7,2)),{1,2,3,4,5,6,7},{1,1,1,1,1,2,0}),2)>5,TEXT($B$3,"hh:mm"),TEXT($B$2,"hh:mm"))
    Last edited by AliGW; 08-20-2016 at 11:39 AM.

  7. #7
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

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

  8. #8
    Registered User
    Join Date
    08-20-2016
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    18

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Hi AliGW, thanks but you are text editing. Sorry for the late reply.
    What I want is to use a method which involves evaluating what date it is and making calculations dependent on what date it is.
    Please see the attached for the method I have in mind- I need to be able to drag the formula to create more output.

    Basically, my formula needs a new structure for its IF statements. Can you please do that?
    Attached Files Attached Files
    Last edited by chilledmalt; 08-21-2016 at 01:43 AM.

  9. #9
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    There was nothing in your original file (which you have replaced with a new one in your opening post this morning) or in your opening post to tell us that a text output would not acceptable. Why did you not include your attempt at the formula in the file you posted first? It would have saved me an hour of unnecessary work yesterday.

    Why do you want a repeat of August dates under the other months?
    Last edited by AliGW; 08-21-2016 at 03:10 AM.

  10. #10
    Registered User
    Join Date
    08-20-2016
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    18

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Oh, I am sooo sorry, Aligw! You are right. I thought it would be obvious but I can see how it isn't necessarily. Please accept my apology. From now on I will always show my attempt in any file I upload.

  11. #11
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    In B7 copied across:

    =EDATE(B6,0)+(8.5/24)

    In B8 copied across and down:

    =IF(WEEKDAY(B7,1)=6,EDATE(B7,0)+1+(9/24),IF(WEEKDAY(B7,1)=7,EDATE(B7,0)+2+(8.5/24),EDATE(B7,0)+1+(8.5/24)))

    To make the list stop at the end of the month as you drag down, use this in B8 copied across and down:

    =IFERROR(IF(EDATE(B7,0)+1=EDATE(B$6,1),"",IF(WEEKDAY(B7,1)=6,EDATE(B7,0)+1+(9/24),IF(WEEKDAY(B7,1)=7,EDATE(B7,0)+2+(8.5/24),EDATE(B7,0)+1+(8.5/24)))),"")
    Last edited by AliGW; 08-21-2016 at 03:44 AM.

  12. #12
    Registered User
    Join Date
    08-20-2016
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    18

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Thanks ALIGW
    But there's one small part that is not working to make it 100%. Please see attachment.
    Attached Files Attached Files

  13. #13
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    So, in B7 copied across:

    =IF(WEEKDAY(EDATE(B6,0),1)=1,EDATE(B6,0)+1+(8.5/24),EDATE(B6,0)+(8.5/24))

    Are we there now?

  14. #14
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Not quite! Better make that:

    =IF(WEEKDAY(EDATE(B6,0),1)=1,EDATE(B6,0)+1+(8.5/24),IF(WEEKDAY(EDATE(B6,0),1)=7,EDATE(B6,0)+(9/24),EDATE(B6,0)+(8.5/24)))

    in case the first day of the month is a Saturday.

  15. #15
    Registered User
    Join Date
    08-20-2016
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    18

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Thanks, let me check it by evening and give you the rep!

  16. #16
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Let us know how you get on.

  17. #17
    Registered User
    Join Date
    08-20-2016
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    18

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    It's perfect! Thanks billion AliGW!!!

  18. #18
    Registered User
    Join Date
    08-20-2016
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    18

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Can you explain how you developed the formula for me to understand how to build something like this, please?

  19. #19
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    I'll do my best! Give me a moment.

  20. #20
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    OK, so the formula in B7:

    =IF(WEEKDAY(EDATE(B6,0),1)=1,EDATE(B6,0)+1+(8.5/24),IF(WEEKDAY(EDATE(B6,0),1)=7,EDATE(B6,0)+(9/24),EDATE(B6,0)+(8.5/24)))

    The section in red uses the EDATE function: EDATE(B6,0) returns the date of B6 at 00:00 hours. (For your understanding, EDATE(B6,1) would return the same date, but one month on.) It then checks if that date in B6 is a Sunday.

    If the above is true, the green bit adds one day and 8 and a half hours to the zero-hour date in B6.

    The blue bit checks if the date in B6 is a Saturday.

    If B6 is a Saturday, the bit in orange adds 9 hours to it.

    The final bit of the formula adds 8 and a half hours to the date in B6 if it's not a Sunday or a Saturday.

    This makes sure that your start date is correct. I'll break down the second formula in another post.
    Last edited by AliGW; 08-21-2016 at 08:32 AM.

  21. #21
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Now for the formula in B8:

    =IFERROR(IF(EDATE(B7,0)+1=EDATE(B$6,1),"",IF(WEEKDAY(B7,1)=6,EDATE(B7,0)+1+(9/24),IF(WEEKDAY(B7,1)=7,EDATE(B7,0)+2+(8.5/24),EDATE(B7,0)+1+(8.5/24)))),"")

    The section in red checks if the date in B7 plus one day would be B6 plus one month, and if it is (i.e. if B7 plus one day is September), it returns a blank cell. This stops a result showing once you've reached the end of the month.

    The bit in green checks if the weekday of B7 is a Friday, and if it is, it adds one day and 9 hours to it.

    The next section in orange checks if B7 is a Saturday, and if it is, it adds two days and 8 and a half hours to it.

    The last bit of the formula returns what you would need for any other weekday, i.e. B7 plus one day and 8 and a half hours.

    The =IFERROR(...,"") round the whole thing ensures that you don't get a value error message showing once you drag down past the end of the month in that column.

    Hope this helps.

    I think I might have earned some rep now.
    Last edited by AliGW; 08-21-2016 at 08:29 AM.

  22. #22
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,288

    Re: Nested IFs to output dates excluding Sundays (Med. - Hard difficulty)

    Thanks for the rep!

+ 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. To calculate number of days excluding sundays
    By palani_k15 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-22-2014, 09:02 AM
  2. excluding holidays and sundays
    By balundl in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-25-2013, 12:38 PM
  3. [SOLVED] creating a list of running dates excluding sundays
    By bite_tony in forum Excel General
    Replies: 2
    Last Post: 04-18-2012, 07:40 AM
  4. Dates Excluding Sundays
    By gailb14 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 12-07-2007, 12:16 PM
  5. counting days excluding saturdays and sundays
    By p_dhoke in forum Excel General
    Replies: 2
    Last Post: 04-24-2007, 04:34 AM
  6. [SOLVED] Excel - list days of a month, excluding Sundays
    By John in forum Excel General
    Replies: 1
    Last Post: 01-03-2006, 12:50 PM
  7. Subtract Dates excluding Saturdays and Sundays
    By Shirley Munro in forum Excel General
    Replies: 2
    Last Post: 01-14-2005, 06:26 AM

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