If your concept of a business day is a week day, then merlyn's code will work.

However if holidays matter to you, life is going to turn into a mess. The relevant holidays for a business depend on its country, state, city, and what industry it is in. Furthermore the definition of what the holidays will be for a given industry (eg stocks or bonds) is often only decided a few months in advance. This is particularly problematic when the holiday falls on a weekend, which weekday is a holiday? (I believe that the stock market changed its mind on how to handle Jan 1, 2000 fairly close to the date.) Also if you code a solution now and wait a few years, well the politicians will change what the holidays are so your perfectly good solution is now broken.

Plus it varies by company. For instance two companies in the same city and industry may differ on whether they are taking the Friday after Thanksgiving as a holiday. Officially it is not. Unofficially, well that is a different story.

In short, you have a simple-seeming request. But the more that you look into it, the more complex it will get, and there is no good generic solution. So my advice is to decide how important it is to get it right, and then decide on how you will maintain the holiday list going forward (because it will need maintainance). Either that or go with a known broken but mainly accurate solution like the one that merlyn gave.


In reply to Re (tilly) 1: Business Date(s) by tilly
in thread Business Date(s) by data67

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.