DBAsupport.com Forums - Powered by vBulletin
Results 1 to 8 of 8

Thread: SQL Problem Urgent

  1. #1
    Join Date
    Mar 2004
    Posts
    14

    SQL Problem Urgent

    Hi.
    Any one let me know why this is happening.

    My SQL
    Select to_date('01-SEP-2004','YYYY/MM/DD HH24:MI:SS') from dual

    Output:
    9/20/0001 4:00:00 AM

    Its suppose to be 2004/09/01

    We are using Oracle 8i 8.1.7

    Thanks

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Look at what you coded. You said:
    YYYY = 01
    MM = SEP
    DD HH24 = 2004

    http://download-west.oracle.com/docs...a85397/toc.htm

    I suspect you need to_char(to_date(.......)) - I'll leave the details for you to fill in: good learning excerise
    Last edited by DaPi; 09-23-2004 at 08:32 AM.

  3. #3
    Join Date
    Mar 2004
    Posts
    14
    Hi dapi.

    I already did that. but i need to pass as date not char.

  4. #4
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    '01-SEP-2004' is a character string

    Does this help your thought process?
    Code:
    Select to_char(SYSDATE, 'YYYY/MM/DD HH24:MI:SS') from dual
    
    TO_CHAR(SYSDATE,'YY
    -------------------
    2004/09/23 14:46:35
    Last edited by DaPi; 09-23-2004 at 08:47 AM.

  5. #5
    Join Date
    Mar 2004
    Posts
    14
    Hi dapi.
    No, I need to send date, not char.

    Thanks

  6. #6
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253

    Re: SQL Problem Urgent

    Originally posted by ba1234
    Hi.
    Any one let me know why this is happening.

    My SQL
    Select to_date('01-SEP-2004','YYYY/MM/DD HH24:MI:SS') from dual

    Output:
    9/20/0001 4:00:00 AM

    Its suppose to be 2004/09/01

    We are using Oracle 8i 8.1.7

    Thanks
    Well the date format picture in the To_Date() function is supposed to match the format that you have used to write the date as in the string.
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  7. #7
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142

    Re: SQL Problem Urgent

    If you want a DATE as output, why did you confuse the issue by posting two different char representations of it?
    Originally posted by ba1234
    Output:
    9/20/0001 4:00:00 AM

    Its suppose to be 2004/09/01

  8. #8
    Join Date
    Mar 2002
    Posts
    534
    Hi,

    As DaPi and Slimadave already said, the problem is that your date format is wrong.

    You are using:
    to_date('01-SEP-2004','YYYY/MM/DD HH24:MI:SS')

    But it should be:
    to_date('01-SEP-2004','DD-MON-YYYY')

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