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: this cannot be then best way

Re: this cannot be then best way

From: Vladimir M. Zakharychev <vladimir.zakharychev_at_gmail.com>
Date: 16 Jul 2006 01:50:32 -0700
Message-ID: <1153039832.031775.28570@p79g2000cwp.googlegroups.com>


DA Morgan wrote:
> g wrote:
> > I have a date mydate and i want to subtract X working days off
> >
> > i was thinking of something like
> >
> > loop while x > 0
> > if to_char(mydate,'d') < 6 then
> > x = x -1
> > endif
> > mydate :mydate - 1
> > endloop
> >
> > any ideas
>
> Just a quick note: TO_CHAR does not produce a number and
> essentially none of the code, above, is valid. It will
> never run in Oracle. What product do you have?

It will, as PL/SQL engine will implicitly apply TO_NUMBER() to the result of TO_CHAR() in attempt to match types of the values being compared. Not a good idea to rely on implicit type conversion though (at least until 10g where it seems to be more efficient than explicit conversion sometimes.)

Regards,

    Vladimir M. Zakharychev
    N-Networks, makers of Dynamic PSP(tm)     http://www.dynamicpsp.com Received on Sun Jul 16 2006 - 03:50:32 CDT

Original text of this message

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