Solved

SQL datetime where selection

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
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…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
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.

707 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

20 Experts available now in Live!

Get 1:1 Help Now