Solved

SQL datetime where selection

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to recover a database from a user managed backup

751 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