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

Home -> Community -> Usenet -> c.d.o.server -> Re: confusing date question

Re: confusing date question

From: Srinivasa Medam <msrhome_at_yahoo.com>
Date: 22 Jul 2002 14:47:21 -0700
Message-ID: <a682873e.0207221347.6aa69927@posting.google.com>


select

        case when to_char(sysdate, 'Dy') = 'Sat' then Sysdate + 2
             when to_char(sysdate, 'Dy') = 'Sun' then Sysdate + 1
        else sysdate end from dual; 

Hope this helps !!

In other words for your query

UPDATE GL_ACCT_SCHED SET EFF_DT =
    (case when to_char(EFF_DT, 'Dy') = 'Sat' then EFF_DT + 2 /* if sat add 2 */

          when to_char(EFF_DT, 'Dy') = 'Sun' then EFF_DT + 1 /* if sun add 1 */
        else EFF_DT end                              /* else take it as is */
 where MONTHS_BETWEEN(TO_DATE('01-JAN-2001', 'DD-MON-YYYY'), EFF_DT) > 0;

Hope it works .

thanks,
Srinivasa

"Cynic" <ksd9_at_yahoo.com> wrote in message news:<ujo5lph3aqop76_at_corp.supernews.com>...
> 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;
Received on Mon Jul 22 2002 - 16:47:21 CDT

Original text of this message

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