Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 31st, 2004, 01:39 AM
chelleybaby chelleybaby is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 20 chelleybaby User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question How do u select a date in oracle???

When i type what is below, i get the order_entrydate returned for that ID. This order_entrydate was generated by sysdate in my asp code to oracle.

SQL> select order_entrydate from orders where order_id=1;

ORDER_ENT
---------
31-MAR-04


However, when i do it the opposite way, there are no rows selected. I tried various formats for the date, but i cant seem to return anything. what went wrong??

SQL> select order_id from orders where order_entrydate='31-Mar-04';

no rows selected

Reply With Quote
  #2  
Old March 31st, 2004, 03:21 AM
galith_haham galith_haham is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 64 galith_haham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 25 m 17 sec
Reputation Power: 5
Hi,

When you do a date-'14-3-2004' it tries to match the date along with the hour (which in this case is 00:00:00) whereas the date column in the table is in a different hour/minut/second -

try

alter session set nls_date_format='dd-mm-yyyy hh24:mi:ss'

and repeat.

Reply With Quote
  #3  
Old March 31st, 2004, 01:37 PM
jimbag8 jimbag8 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 28 jimbag8 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
trunc() function

Or, and a left side function like this is not optionmal, but you could just make your where clause
trunc(order_date) = '31-MAR-04' ;

*or*

use a between...

order_date between (trunc(order_date))
and (trunc(order_date + 1))



You may need to use a hint in the select if there are a lot of records and you decide to go with the left side trunc. This will do some consintent gets and physical reads.

Last edited by jimbag8 : March 31st, 2004 at 01:42 PM.

Reply With Quote
  #4  
Old April 1st, 2004, 02:59 AM
KIRTI KIRTI is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 2 KIRTI User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

Try this :

select order_id from orders
where order_entrydate=to_date('31-Mar-04');

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > How do u select a date in oracle???


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway