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

x
?
Solved

Oracle Sysdate question

Posted on 2011-03-09
2
Medium Priority
?
436 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
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.
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.

721 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