Solved

Oracle Sysdate question

Posted on 2011-03-09
2
434 Views
Last Modified: 2012-05-11
I have a query that selects records based upon date < sysdate - 10, to get the past 10 days of actions.  However, I just found out that I need it to be sysdate - 10 @ midnight.  How can I do this within my SQL Statement.  
0
Comment
Question by:jmpatton
[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
2 Comments
 
LVL 12

Accepted Solution

by:
enachemc earned 500 total points
ID: 35082120
trunc(sysdate) - 10
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35082317
If your date column also has a time portion you will need to trunc that as well.

FYI: Using trunc on the date column will not make use of any index on the column.  If the column is indexed and you need to use it you will have to use:

date_column > trunc(sysdate)-11 and date_column <= trunc(sysdate)
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
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…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

752 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