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: Last Week

Re: Last Week

From: Jim Kennedy <kennedy-downwithspammersfamily_at_attbi.com>
Date: Sun, 26 Jan 2003 20:08:50 GMT
Message-ID: <mfXY9.49117$Ve4.6008@sccrnsc03>


select ... from ... where
the_date_field >= trunc((sysdate-7)) and the_date_field<=trunc(sysdate)

That gets you what you want for the last 7 days. sysdate is now. doing a trunc on it gets you today at midnight, subtracting whole numbers subtracts days. Not sure what your definition of last week is, but that would help or

select ... from ... where
to_char(the_date_field ,'IW')>=(to_char(sysdate,'IW')-1) and to_char(the_date_field ,'IW')<=(to_char(sysdate,'IW')-1)

to_char( date, date_format) IW is the week number. The above won't work when you go over a year, but this should give you a start. Jim

"Bill" <va3wmh_at_rac.ca> wrote in message
news:68a1410e.0301261141.31224e91_at_posting.google.com...
> I'm not an Oracle developer but I've been told that it is not possible
> to create a query that will select records with a date field for last
> week. I've developed an application in MS Access and the Oracle
> people have been trying to convert into into a Oracle query. I simply
> wished to select records from a table for the previous week. Can
> anyone out there provide a general sql query that will work in Oracle?
>
> Your help is appreciated.
>
> Cheers;
>
> Bill
Received on Sun Jan 26 2003 - 14:08:50 CST

Original text of this message

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