If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > select query returns empty table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-30-12, 05:39
Shikhashah Shikhashah is offline
Registered User
 
Join Date: Jan 2012
Posts: 9
Exclamation select query returns empty table

I am trying to fetch some records from a table using

Quote:
select * from web_log where log_date = to_date('30-Jan-2012','dd-mon-yyyy')
it is working fine but returns an empty table however there is value in table.
It returns row if I query

Quote:
select max(log_date) from web_log
result- 30-JAN-12


can anybody have solution?
Reply With Quote
  #2 (permalink)  
Old 01-30-12, 05:52
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
Please show us the result of:
Code:
SELECT to_char(max(log_date), 'dd-mon-yyyy'))
FROM web_log
My gues is, that the max date you are seeing is actually 30-JAN-1912
Reply With Quote
  #3 (permalink)  
Old 01-30-12, 06:16
Littlefoot Littlefoot is offline
Lost Boy
 
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 3,629
My guess is that LOG_DATE contains time component (i.e. '30-jan-2012' is, actually, something like '30-jan-2012 13:23:22').

So, what happens if you try
Code:
select *
from web_log
where trunc(log_date) = to_date('30-jan-2012', 'dd-mon-yyyy')
Reply With Quote
  #4 (permalink)  
Old 01-30-12, 06:59
Shikhashah Shikhashah is offline
Registered User
 
Join Date: Jan 2012
Posts: 9
it worked

yes it worked
Reply With Quote
  #5 (permalink)  
Old 01-30-12, 07:12
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
Quote:
Originally Posted by Littlefoot View Post
My guess is that LOG_DATE contains time component (i.e. '30-jan-2012' is, actually, something like '30-jan-2012 13:23:22').
Very good point. Should have thought of that myself
Reply With Quote
Reply

Tags
select query

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On