Date - Query with no rows returned -Strange !!!
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: Date - Query with no rows returned -Strange !!!

  1. #1
    Join Date
    Dec 2000
    Posts
    87

    Unhappy

    Dear all,

    I have come across this problem:

    Database version: 8.1.7
    Client: 9i

    When I issue a query like below from the client:

    select * from t
    where date_col=to_date('2002/08/26','yyyy/mm/dd');

    it returns no rows, although the records do exist.

    The records only appear if I change query like this:

    select * from t
    where date_col>=to_date('2002/08/26','yyyy/mm/dd');

    why is this so??? can someone explain this?

    Is there any settings needed to be corrected?

    Thanks in advance.


  2. #2
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    You're not respecting the time component of the date (ie. there are no records at midnight of your date). Try:
    Code:
    select * from t
    where trunc(date_col)>=to_date('2002/08/26','yyyy/mm/dd');
    Jeff Hunter
    marist89@yahoo.com
    http://marist89.blogspot.com/
    Get Firefox!
    "I pledge to stop eating sharks fin soup and will not do so under any circumstances."

  3. #3
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    One too many '>' characters in jeff's post. What he probbably realy ment was
    Code:
    select * from t
    where trunc(date_col)=to_date('2002/08/26','yyyy/mm/dd');
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

  4. #4
    Join Date
    Dec 2000
    Posts
    87

    Unhappy

    Hi both,

    Thanks for your reply.
    However, I tried your codes, it doesn't seem to be working, and I don't think 'time' here is the real issue. Since by using to_date(date_col,'yyyy/mm/dd'), the time should be eliminated from the query (although it's still exist).

    Any new thoughts? Thanks.

  5. #5
    Join Date
    Dec 2000
    Posts
    87

    Smile

    Sorry both...your answer is actually working...
    Thanks for your great help!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width