Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ORACLE previous week date function

Posted on 2012-03-14
3
Medium Priority
?
1,293 Views
Last Modified: 2012-03-15
I'd like to create a report which will run every Monday morning showing data for the previous week; Sun - Sat.

CLOSED_DTTM > trunc(SYSDATE)- 7 is not working.

What should I use?

Thanks.
0
Comment
Question by:saved4use
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 20

Accepted Solution

by:
flow01 earned 2000 total points
ID: 37722881
WHERE CLOSED_DDTM >=  trunc(sysdate - 7,'WW')
AND    CLOSED_DDTM <  trunc(sysdate,'WW')

The WW truncation gives as start of the week: sunday 00.00 hrs
0
 

Author Comment

by:saved4use
ID: 37723006
Will the above work even when, say,  the middle of the week is a new month?
0
 
LVL 16

Expert Comment

by:Wasim Akram Shaik
ID: 37723391
yes author, the solution which flow01 will work fine even in case the middle of week is a new month...

what in actual it does it, it truncates the day to start of the week,..

for example 01/Mar/2012 is thursday,

select trunc(to_date('01-Mar-2012','DD-Mon-YYYY'),'WW') from dual

this will result in 26th Feb 2012, which is start of the week and by default the start of week in oracle is sunday..
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Via a live example, show how to take different types of Oracle backups using RMAN.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question