Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Oracle Sysdate question

Posted on 2011-03-09
2
Medium Priority
?
438 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 2000 total points
ID: 35082120
trunc(sysdate) - 10
0
 
LVL 78

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

971 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