Solved

Oracle Sysdate question

Posted on 2011-03-09
2
430 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
2 Comments
 
LVL 12

Accepted Solution

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to recover a database from a user managed backup

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now