Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2006

    Unanswered: Problem formatting date


    This is the first time I am working with Oracle and I am really stuck with this problem. I have a date value that the user selects which is in the format mm/dd/yyyy hh:mi:ss AM/PM. This is a string, so i convert it to a date format & try to insert it in the database through my application.
    I am trying to do this:

    to_date('06/01/2007 11:59:36 AM', 'mm/dd/yyyy hh12:mi:ss')
    this gives an error :
    ORA-01830: date format picture ends before converting entire input string

    When I removed "AM" from the user input string, it worked properly but with the AM/PM it gives error.

    Is it possible to keep the AM/PM in the input string & make any change in the date format so that the above statement works & I don't have to remove AM/PM explicitly from the input string.

    Any suggestion or help would really be appreciated.


  2. #2
    Join Date
    Nov 2003
    Provided Answers: 23
    You have to include the position of the AM in the format string:
    select to_date('06/01/2007 11:59:36 AM', 'mm/dd/yyyy hh12:mi:ss AM')
    See the description of format models here

  3. #3
    Join Date
    Nov 2006
    Thanks for the reply.

    It has hepled solve my problem

    Last edited by sweetypie; 06-01-07 at 05:52.

Posting Permissions

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