Skip to main content
Known Participant
July 21, 2009
Question

Subtracting/adding Business days

  • July 21, 2009
  • 1 reply
  • 854 views

Hi everyone !

I have a calendar question: I have a date, number of days (either business or calendar) and Before/After indicator.

I need to calculate the future/past date depending on business/calendar nn days.

Ideally, I will also read Holidays table to fix the result with Holidays.

Any suggestions ?

CF allows me to know a weekday, add/subtract units from dates, compare dates, but nothing in the direction I mentioned...

Any suggestions will be greatly appreciated !

Gary.

    This topic has been closed for replies.

    1 reply

    Inspiring
    July 21, 2009

    Make it very easy on yourself:  set up a database table with date as the primary-key, then fill it with 200 years' worth of dates.  ("When you run out, dig me up and I'll fix it then ...")  You can put any sort of information you want to in there, such as (for example...) a "business-day number" that's used only to calculate these differences.  It can literally be anything-and-everything you need to know about dates at your place of business.

    When you do this, not only are "complicated calculations" eliminated at-a-stroke, but you can very easily change anything at will.  You're simply using an inner-join and ... voila ... the answer is there.

    Although setting up a script (in whatever language) to populate the table is a bit tedious, you only need to do it once.  To me, it beats every other approach hands-down.

    Inspiring
    July 21, 2009

    I agree that a calendar table is by far the better option. Especially if you need to add holidays into the mix. But if you absolutely must do this in CF, check over at cflib.org.  I do not remember the function name, there is one for adding business days.

    GaryNYAuthor
    Known Participant
    July 21, 2009

    Thank you- I figured out a function for add/subtract business days.

    Holidays are different (a little) between companies, so this table has to

    be supported (may be auto-downloaded from some source- I will look)

    I really would rather not create a business days table with all further

    convenience.

    But, again, thank you for your help !

    Really appreciated

    Gary.