DBAsupport.com Forums - Powered by vBulletin
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Date Format (Urgent)

  1. #1
    Join Date
    Feb 2000
    Location
    New York,U.S.A.
    Posts
    245
    Hi, could somebody help me this out?
    When I do
    SQL> select xmlbody from messagearchive where arrivaltime = '09-DEC-00';

    no rows selected

    But I am sure there are data for xmlbody. I just do not remember how to deal with date here. Thanks for help.

  2. #2
    Join Date
    Oct 2000
    Location
    Dallas:TX:USA
    Posts
    407
    Try this --

    select xmlbody from messagearchive where to_char(arrivaltime, 'DD-MON-YY') = '09-DEC-00';

    You may want to read more about to_date and to_char functions and the allowed Date formats.

    - Rajeev


  3. #3
    Join Date
    Feb 2000
    Location
    New York,U.S.A.
    Posts
    245
    Thanks, Rajeev,
    I tried your query, it still shows no rows selected.

  4. #4
    Join Date
    Oct 2000
    Location
    Cambridge, MA (Boston)
    Posts
    144
    Rajeev's method should work. try loosening up your criteria just to select out what the values are (E.G. "select to_char(arrivaltime, 'DD-MON-YY HH24:MI:SS') from messagearchive where arrivaltime between to_date('09-DEC-00', 'DD-MON-YY') and to_date('10-DEC-00', 'DD-MON-YY') ".

    as a side issuer, you may need to create an index-based function for using to_char(arrivaltime, 'DD-MON-YY') without forcing a full table scan.

    D.

  5. #5
    Join Date
    Feb 2000
    Location
    New York,U.S.A.
    Posts
    245
    Sorry, it still does not work.

  6. #6
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    I think you could try

    select xmlbody from messagearchive where to_char(arrivaltime, 'DD-MM-YY') = '09-12-00';

    'Mon' is kinda tricky to deal with....


  7. #7
    Join Date
    Nov 2000
    Location
    greenwich.ct.us
    Posts
    9,092
    To make sure you have the data you think you do, try:
    select to_char(min(arrivaltime),'mm/dd/yyyy hh24:mi:ss')
    from messagearchive
    /
    select to_char(max(arrivaltime),'mm/dd/yyyy hh24:mi:ss')
    from messagearchive
    /
    select to_char(arrivaltime,'mm/dd/yyyy hh24:mi:ss') atime, count(*)
    from messagearchive
    group by to_char(arrivaltime,'mm/dd/yyyy hh24:mi:ss')
    /
    Jeff Hunter

  8. #8
    Join Date
    Feb 2000
    Location
    New York,U.S.A.
    Posts
    245
    Thanks,Jeff,
    I am sorry to you all, there is no data for 09-12-00, but 19-12-00. So the query works

    select xmlbody from messagearchive where to_char(arrivaltime, 'DD-MM-YY') = '19-12-00'

    Thanks to all of you for prompt response.


  9. #9
    Join Date
    Nov 2000
    Location
    Baltimore, MD USA
    Posts
    1,339
    Minor point I feel I have to add.

    Optimizationally-speaking (if that's a term), *never* put the conversion function on the column. You never want to take the date column and convert it to a string to test against a value. You will lose any possibility of using an index, assuming one had existed on that column. Even without an index, you are now performing a function call for every single row you are testing as opposed to the single call necessary to convert the constant.

    Just my .02

    - Chris

  10. #10
    Join Date
    Jan 2001
    Posts
    318
    I think in which case.. this will work
    select xmlbody from messagearchive
    where trunc(to_date(arrivaltime, 'DD-MM-YY')) = trunc(to_date('19-12-00' , 'DD-MM-YY'))

    Sonali

    Sonali

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