Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Confusing nested date question

Re: Confusing nested date question

From: Daniel Morgan <dmorgan_at_exesolutions.com>
Date: Mon, 22 Jul 2002 15:28:31 GMT
Message-ID: <3D3C245D.CB41B4D3@exesolutions.com>


Cynic wrote:

> I have a script that updates dates on a db. However, now I am supposed to
> take into account the day of the week. So, for example, if the date is July
> 7, 1999 (Wednesday) I need to update to July 7, 2001. HOWEVER: if July 7,
> 2001 is NOT a thursday, but a SATURDAY, I need to make it a non-weekend work
> day. So here is what I need to do:
>
> July 7, 1999 ---->>> July 9, 2001 (this is the first work day following
> July 7, 2001)
> So, I guess I am adding 2 years here PLUS whatever it will take to get the
> day to the work week.
> Any suggestions?
>
> Here is what I have so far (doesn't take into consideration the whole
> weekend thing):
>
> UPDATE GL_ACCT_SCHED SET EFF_DT = ADD_MONTHS(EFF_DT,
> (TRUNC((MONTHS_BETWEEN( TO_DATE('31-DEC-2000', 'DD-MON-YYYY'),
> EFF_DT))/12,0)*12)+12) where MONTHS_BETWEEN(TO_DATE('01-JAN-2001',
> 'DD-MON-YYYY'), EFF_DT) > 0;
Unless there is some overwhelming need to do this in a single SQL statement why not just write a simple stored procedure with a cursor loop.

Determine the day number of the day plus two years. And if it is a Saturday add two, or a Sunday, add one.

One SQL statement might take hours to write and test. A stored procedure to do it five minutes.

Daniel Morgan Received on Mon Jul 22 2002 - 10:28:31 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US