+ Reply to Thread
Results 1 to 7 of 7

creating a list of weekend and holiday dates

  1. #1
    Registered User
    Join Date
    06-25-2022
    Location
    chicago
    MS-Off Ver
    365
    Posts
    3

    creating a list of weekend and holiday dates

    Hi all,
    Long time lurker, first time poster here

    I'm having trouble creating a formula that generates a list of weekend dates and holidays. And for this purpose I'm considering Friday to be a weekend day.

    I started with workday.intl(A3,1,"1111000") where A3 is date(B1,1,1). The year is specified in B1 so I can copy forward this sheet for years to come. The holidays I generate with formulas so that is dynamic and will adjust from year to year. If the holiday falls on a Sat/Sun, it is observed on the previous/following weekday. That is to say if Christmas is on Sunday then Monday is considered a day off.

    So I created a named range of these observed dates to include into my calendar/list.

    =if(countif(ObservedDates,$A12+1)>0,$A12+1,workday.intl($A12,1,"1111000"))

    Unfortunately this formulas misses all holidays that fall on Tue, Wed, or Thu.

    Anyone have thoughts or ideas? Thanks for reading!
    -Michelle
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,000

    Re: creating a list of weekend and holiday dates

    If you have signed up for the Beta Office Insider programme, you will have VSTACK... and can use this:

    =LET(d,SEQUENCE(365,,DATE(B1,1,1)),f,FILTER(d,(WEEKDAY(d,2)>=5)),SORT(VSTACK(f,ObservedHolidates)))

    If not, there will be a workaround...

    To return the holiday names:
    =IFERROR(INDEX(Holidays,MATCH(A12,ObservedHolidates,0)),"")
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,000

    Re: creating a list of weekend and holiday dates

    If you don't have VSTACK... you can use this:

    =LET(d,SEQUENCE(365,,DATE(B1,1,1)),f,FILTER(d,(WEEKDAY(d,2)>=5)),SORT(UNIQUE(FILTERXML("<x><m>"&TEXTJOIN("</m><m>",,f,ObservedHolidates)&"</m></x>","//m"),FALSE),,1))
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-25-2022
    Location
    chicago
    MS-Off Ver
    365
    Posts
    3

    Re: creating a list of weekend and holiday dates

    Thanks so much for your quick reply! I've never used the Let function so that was very cool to learn.

    I also new to the filterxml function - am I understanding correctly that it is to split the calculations into separate cells rather than have all the results populate one cell?

    I'm excited to try to apply this lesson further because I want to include additional days as holidays. For example, if Christmas falls on a Tue, Wed, Thu, or Fri I'd like to include Christmas day - 1 (aka Christmas eve) as a holiday. So hear me out, I think I should be able to generate that list using the Let function just like you showed me. Don't give me the answer, I'm going to try and crunch this out myself

    Thanks again for all your knowledge!

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,000

    Re: creating a list of weekend and holiday dates

    LET isn't really a function. It allows you to calculate individual bits of a formula, giving them a short name, and re-use them several times without recalculating each time.

    I used TEXJOIN to join the two arrays (the list of observed holidays and the extended weekend days) in a way that

    FILTERXML could separate the dates into a dynamic array that would spill all results into individual cells, finally using

    UNIQUE... just in case any dates occurred in both lists and

    SORT to put them in order.

    If you have any queries, just shout. If not...

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

  6. #6
    Registered User
    Join Date
    06-26-2022
    Location
    Chicago
    MS-Off Ver
    2020
    Posts
    1

    Re: creating a list of weekend and holiday dates

    At what stage do you have difficulty? Maybe I can find working solution here to the problem.

  7. #7
    Registered User
    Join Date
    06-25-2022
    Location
    chicago
    MS-Off Ver
    365
    Posts
    3

    Re: creating a list of weekend and holiday dates

    Sorry for delayed reply but I've been out sick with a cold. Today, I realized how amazing filterxml is. I didn't really understand it the first (or fourth) time I looked at it and it took several more pass-throughs for me to get it. But now I finally see it. What a neat little function!

    Okay. So for the next part of my problem. I want my list of Observed days to include the day before if the holiday falls on Tue, Wed, Thu, or Fri. For instance, if Christmas falls on Friday, then Christmas Eve, Thursday, would be considered a weekend day/non-working day/holiday.

    Now, when one's only tool is a hammer, everything starts to look like a nail. So I tried doing this with my newfound LET tool. Except I don't know how to generate a result of two different dates given one input. You can see what I attempted, which was create a string of incomprehensible numbers. Bummer. Filterxml will separate those values for me but I run into a spill problem because of the values in the cells above and below. .

    Thoughts? You don't have to give me the answer straight away but can you point me in the right direction?
    Attached Files Attached Files

+ 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: 3
    Last Post: 11-11-2021, 05:00 AM
  2. Replies: 2
    Last Post: 06-08-2020, 02:41 PM
  3. [SOLVED] Creating a serious of dates, where the dates never fall on the weekend
    By blackrosepetals9169 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2018, 03:22 AM
  4. [SOLVED] How many WEEKEND DAYS & HOLIDAY DAYS between 2 dates in September
    By leovfx in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-12-2017, 07:32 PM
  5. [SOLVED] IF function using WORKDAYS and a Bank Holiday list - trying to add new holiday dates
    By jowarks in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-05-2013, 05:42 AM
  6. how to sum day if it falls in a weekend or holiday?
    By jgomez in forum Access Tables & Databases
    Replies: 2
    Last Post: 11-30-2011, 01:54 PM
  7. Identifying weekend dates in a list of dd/mm/yy dates
    By Gooford in forum Excel General
    Replies: 4
    Last Post: 01-07-2010, 10:01 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