Re: Adding days past weekend

From: <fitzjarrell_at_cox.net>
Date: Mon, 3 Mar 2008 09:55:33 -0800 (PST)
Message-ID: <5d1ee36e-919e-44da-866b-6203b2805dcc@e60g2000hsh.googlegroups.com>


On Mar 3, 11:20 am, joel garry <joel-ga..._at_home.com> wrote:
> On Feb 29, 1:19 pm, "fitzjarr..._at_cox.net" <fitzjarr..._at_cox.net> wrote:
>
>
>
>
>
> > On Feb 29, 3:14 pm, joel garry <joel-ga..._at_home.com> wrote:
>
> > > On Feb 29, 11:59 am, DJH <NOS..._at_NOSPAM.COM> wrote:
>
> > > >     I would like to add 5 days to sysdate to form a date. That would be
> > > > easy. But I would like to add 5 days to sysdate but roll to the next
> > > > week day if sysdate+5 falls on a weekend. What would be even nicer if
> > > > there was a simple way to add days past federal American holidays was
> > > > well. For now the 1st solution would suffice.
>
> > > > Thanks
>
> > > In addition to what David said, try searching for holiday calendar on
> > > orafaq.com.
>
> > > Seehttp://www.dbaoracle.net/readme-cdos.htmforpostinghints.
>
> > > jg
> > > --
> > > @home.com is bogus.http://www.wired.com/politics/law/news/2008/02/blind_hacker
>
> > Well, shucks, I can give him that link:
>
> >http://www.opm.gov/Operating_Status_Schedules/fedhol/Index.asp
>
> > Federal holiday calendars through 2010.
>
> > David Fitzjarrell
>
> :-)
>
> Actually, I wasn't so specific because I thought the Easter code was
> pretty interesting, and perhaps others would see that and be
> interested too.
>
> One place I contracted at I incorrectly thought they had MLK day off
> [blush].  Different school districts near where I live had different
> interpretations of which days to take off for Presidents day this year
> - Friday/Monday, Monday/Tuesday, Monday only...
>
> jg
> --
> @home.com is bogus.
> All lenders now ask if you've ever walked away, duh.  http://youwalkaway.com/- Hide quoted text -
>
> - Show quoted text -

This code isn't that interesting, really. My initial stab at it worked correctly (but I was choosing the data to pass in); I neglected, however, to account for the fact that the adjustment for weekend dates could create a holiday date as output (ooops). I have since 'corrected' that with an innocuous numeric loop to pass the adjusted value through the process again to clear any further 'holiday' hurdles and return the true next work day. May 19th of this year is a good example:

May 19th + 5 days lands you squarely on Saturday, May 24th. Correcting for the weekend lands you on Monday, May 26th (Memorial Day).

Which would not be correct output, as the next actual work day would be Tuesday, May 27th. Wrapping the logic inside a numeric FOR loop (and there are probably ways using analytics to do this in one pass but I'll let someone else who uses those more often than I do post such a solution) corrected the mis-assigned date output and produces correct results.

Again, it's not glorious code, it's not interesting code, it's code. Basic PL/SQL code. But it works. :D

David Fitzjarrell Received on Mon Mar 03 2008 - 11:55:33 CST

Original text of this message