Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 12th, 2008, 06:50 AM
Newbie
 
Join Date: Aug 2008
Posts: 7
Default Improper result from query

I have written a query:-

select to_date(FILE_START_TIME,'YYYY-MM-DD HH:MI:SSam'), to_date(FILE_END_TIME,'YYYY-MM-DD HH:MI:SSam'), SUBSCRIBER_ID from cms_video_info,video_view_history where cms_video_info.vcode=video_view_history.FILE_ID and vcode='V1111' and video_view_history.FILE_START_TIME >='03-04-2008' OR video_view_history.FILE_END_TIME<='03-04-2008';

TO_DATE(F TO_DATE(F SUBSCRIBER
--------- --------- ----------
26-FEB-08 26-FEB-08 9218181818
14-MAR-08 14-MAR-08 9818675098


now if u see the date entered above is 03-04-2008 (start date) and 03-04-2008 (end date)
now accordingly koi result display nahin hona chahiye tha...as the records do not exist in the given date range. but it is displaying the result.

Now if i write AND instead of OR in the query it gives

select to_date(FILE_START_TIME,'YYYY-MM-DD HH:MI:SSam'),to_date(FILE_END_TIME,'YYYY-MM-DD HH:MI:SSam'),SUBSCRIBER_ID from cms_video_info,video_view_history where cms_video_info.vcode=video_view_history.FILE_ID and vcode='V1111'and video_view_history.FILE_START_TIME >='03-04-2008' and video_view_history.FILE_END_TIME<='03-04-2008';


no rows selected

which is rite but if i change the input dates (date range)
lets say

select to_date(FILE_START_TIME,'YYYY-MM-DD HH:MI:SSam'),to_date(FILE_END_TIME,'YYYY-MM-DD HH:MI:SSam'),SUBSCRIBER_ID from cms_video_info,video_view_history where cms_video_info.vcode=video_view_history.FILE_ID and vcode='V1111'and video_view_history.FILE_START_TIME >='01-01-2008' and video_view_history.FILE_END_TIME<='03-04-2008';

no rows selected

It gives no rows selected. when there exists records in that date range.

Please help?
:)
Reply
  #2  
Old August 12th, 2008, 07:59 AM
Administrator
 
Join Date: Sep 2006
Posts: 11,312
Default

Are those columns dates or varchars?
Reply
  #3  
Old August 12th, 2008, 09:48 AM
Newbie
 
Join Date: Aug 2008
Posts: 7
Default

Those columns are varchar.
Reply
  #4  
Old August 12th, 2008, 09:59 AM
Administrator
 
Join Date: Sep 2006
Posts: 11,312
Default

Quote:
Originally Posted by raghuvendra
Those columns are varchar.
They need to be dates if you want to do date comparisons on them.
Right now they are being compared as strings.
Reply
  #5  
Old August 12th, 2008, 10:27 AM
Newbie
 
Join Date: Aug 2008
Posts: 7
Default

Quote:
Originally Posted by r035198x
They need to be dates if you want to do date comparisons on them.
Right now they are being compared as strings.
Thanks a lot. By the way if want use it as varchars ..then wat should i do?
Reply
  #6  
Old August 12th, 2008, 10:41 AM
Administrator
 
Join Date: Sep 2006
Posts: 11,312
Default

Quote:
Originally Posted by raghuvendra
Thanks a lot. By the way if want use it as varchars ..then wat should i do?
That would not be the natural way of storing dates but you could convert the varchars to dates before the comparisons using the TO_DATE function.
Reply
  #7  
Old August 12th, 2008, 10:52 AM
Newbie
 
Join Date: Aug 2008
Posts: 7
Default

Thanks buddy. You were a great help.
Reply
  #8  
Old August 12th, 2008, 11:00 AM
Administrator
 
Join Date: Sep 2006
Posts: 11,312
Default

Quote:
Originally Posted by raghuvendra
Thanks buddy. You were a great help.
Welcome.
P.S You may want to take part in this chat session. Ignore all the posts by Jos in that thread.
Reply
Reply

Bookmarks

Thread Tools

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 Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles