Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Last Week
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
![]() |
![]() |