Solved

SQL datetime where selection

Posted on 2011-03-24
4
422 Views
Last Modified: 2012-06-27
We have an Oracle backend database that I am trying to select records from where the field EntryDate >= 08/26/2010  

EntryDate is in the DateTime format, so not a string, and I have been unsuccesful and forming a query to accomplish this.  

If I output the data to the screen for a praticular record I get

2010-08-26 00:00:00

even trying a selection of

Select First_Name FROM students WHERE EntryDate ='08/26/2010'
or
Select First_Name FROM students WHERE EntryDate ='2010-08-26 00:00:00'  

I get no results.  Can anyone help me form a query to get this accomplished.
0
Comment
Question by:NoodlesWIU
  • 2
4 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 35209854
Select First_Name FROM students
WHERE EntryDate >= '2010-08-26'  
  AND EntryDate <  '2010-08-27'  
0
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 35209869
Select First_Name FROM students WHERE trunc(EntryDate) =to_date('08/26/2010','MM/DD/YYYY');

if there is an index on entryDate trunc will not use it

then try:

Select First_Name FROM students WHERE EntryDate >=to_date('08/26/2010','MM/DD/YYYY') and EntryDate < to_date('08/27/2010','MM/DD/YYYY');
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 35209884
>>EntryDate >= '2010-08-26'  

I always recommend explicit data type conversions.  Then there can be no confusion.
0
 
LVL 3

Author Closing Comment

by:NoodlesWIU
ID: 35212819
I just used the second option you gave.  I didnt know you could explicitly define it.  Thanks!
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

864 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

16 Experts available now in Live!

Get 1:1 Help Now