Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2012
    Posts
    15

    Exclamation Unanswered: select query returns empty table

    I am trying to fetch some records from a table using

    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

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


    can anybody have solution?

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    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

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    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')

  4. #4
    Join Date
    Jan 2012
    Posts
    15

    it worked

    yes it worked

  5. #5
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    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

Tags for this Thread

Posting Permissions

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