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

x
?
Solved

SQL datetime where selection

Posted on 2011-03-24
4
Medium Priority
?
436 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 143

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 78

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 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 78

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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

916 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