Solved

SQL datetime where selection

Posted on 2011-03-24
4
428 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 77

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 77

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
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 setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

713 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