Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL retrieving last two months
Aha! You've added to the spec.
Most likely you'll have to do this programmatically. Fetch the SYSDATE into a variable and then perform date arithmetic. You can use the TRUNC and ROUND functions to establish the beginning of the month(s) once you have done so.
In article <afhnn2$nb$1_at_news.ost.eltele.no>, "Per Magne" <perman_at_online.no> wrote:
> This only gives you the last 60 days.
> I want to get each month separately.
>
>
> "ImPrecise" <f_puhan_at_precise.com> skrev i melding
> news:f_puhan-939910.08495128062002_at_vienna7.his.com...
> > In article <afhljn$cc$1_at_news.ost.eltele.no>,
> > "Per Magne" <perman_at_online.no> wrote:
> >
> > > I need to have an SQL selecting all records from the past two months
> (this
> > > month and last month).
> > >
> > > Anybody having a solution on this problem (especially December /
> January)?
> > >
> > >
> > >
> > >
> > >
> > > Ex. Table:
> > >
> > > RECNO int
> > >
> > > DATE datetime
> > >
> > > TITLE char(40)
> >
> > I don't currently have the time to hack out the code, but I suspect your
> > best way to do this is to use SYSDATE and SYSDATE - 60 in your WHERE
> > clause. Something like
> >
> > SELECT
> > RECNO, DATE, TITLE
> > FROM
> > table
> > WHERE
> > DATE between SYSDATE and (SYSDATE - 60)
> > /
> >
> > Hth,
> >
> > --
> > The underscore character does not belong in my address. You know the
> drill...
> > ***
> > Anyone sufficiently smart enough to configure and use USEnet for research
> should
> > be smart enough to Read The Freakin' Documentation!
>
>
-- The underscore character does not belong in my address. You know the drill... *** Anyone sufficiently smart enough to configure and use USEnet for research should be smart enough to Read The Freakin' Documentation!Received on Fri Jun 28 2002 - 09:07:50 CDT