Solved

Oracle Sysdate question

Posted on 2011-03-09
2
435 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be ā€¦
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ā€¦
Via a live example, show how to take different types of Oracle backups using RMAN.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

630 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