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: Andy <andy.spaven_at_eps-hq.co.uk>
Date: Tue, 28 Jan 2003 11:53:37 -0000
Message-ID: <c6uZ9.2$A14.637@newsr2.u-net.net>


Bill

If you're still trying to solve this one try the following: -

select trunc(sysdate) - (to_number(to_char(sysdate,'D'))+1) - 7 start_of_week

       , trunc(sysdate) - (to_number(to_char(sysdate,'D'))+1) - 1 end_of_week
from dual

Sysdate can be replaced by any date to get the sunday and saturday of the week before.

The 'D' format gets the day of the week so that [to_number(to_char(sysdate,'D'))+1] gives the number of days to subtract from todays date to get the date for the Sunday just gone (or today if today is a Sunday). The -7 and -1 just give you the respective number of days back from that point.

Andy

"Bill" <va3wmh_at_rac.ca> wrote in message
news:68a1410e.0301271425.5ab642e3_at_posting.google.com...
> I'm trying to extract records from a table for last week. I would
> like a sample query that will select those records even over the end
> of the year.
>
> Thanks
>
> Bill
Received on Tue Jan 28 2003 - 05:53:37 CST

Original text of this message

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