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: Michel Cadot <micadot{at}altern{dot}org>
Date: Fri, 29 Sep 2006 07:00:55 +0200
Message-ID: <451ca888$0$25534$626a54ce@news.free.fr>

"pawan_test" <sridhara007_at_gmail.com> a écrit dans le message de 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
|

1/ Don't toppost
2/ Have a look at TO_CHAR function and never rely on implicit conversion:

http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/functions180.htm#i1009324

Regards
Michel Cadot Received on Fri Sep 29 2006 - 00:00:55 CDT

Original text of this message

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