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: oracle question to get Date minus 1

Re: oracle question to get Date minus 1

From: Jim Kennedy <jim>
Date: Fri, 29 Sep 2006 05:10:29 -0700
Message-ID: <eeCdnZGat7b1kYDYnZ2dnUVZ_sadnZ2d@comcast.com>

"pawan_test" <sridhara007_at_gmail.com> wrote in message news:1159499888.587715.60460_at_h48g2000cwc.googlegroups.com...
> hello Brian,
>
> thanks for your suggestions.
> this is what i tried.
>
> SQL> select to_date('20060928', 'YYYYMMDD') - 1 from dual;
>
>
> TO_DATE('
> ---------
> 27-SEP-06
>
>
> my desired output in this case is 20060927 but here the output is
> coming as 27-SEP-06.
>
> can you please suggest me how do I get the output as 20060927
>
> thanks a bunch
> mark
>
>
>
> Brian Peasland wrote:
> > pawan_test wrote:
> > > can anyone also please suggest me for the following
> > >
> > > this is oracle question
> > >
> > > say TIME=20060928
> > > desired output: 20060927
> > >
> > > say TIME=20061001
> > > DESIRED output: 20060930
> > >
> > > If i substract one day from 'TIME' i am looking for previous day.
> > >
> > > can anyone please suggest me how do i do this is SQL.
> > >
> > > thanks
> > > mark
> > >
> >
> > Just subtract 1 from the date value. For instance, if the date value is
> > stored in the column MY_DATE, then do the following:
> >
> > SELECT my_date-1 FROM my_table;
> >
> > The above will subtract 1 day from the date value.
> >
> > HTH,
> > Brian
> >
> > --
> > ===================================================================
> >
> > Brian Peasland
> > dba_at_nospam.peasland.net
> > http://www.peasland.net
> >
> > Remove the "nospam." from the email address to email me.
> >
> >
> > "I can give it to you cheap, quick, and good.
> > Now pick two out of the three" - Unknown
>

You are confusing a string representation of a date with the date. Jim Received on Fri Sep 29 2006 - 07:10:29 CDT

Original text of this message

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