Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2011
    Posts
    12

    Unanswered: Convert Julian date into MM/DD/YYYY

    I have a function which calculates the difference of days gone by. A date is entered in the format MM/DD/YYYY, and a number variable is entered in number format.
    I have converted the date to Julien, and then added the number variable. My return is 2455852.
    How do I convert that back into MM/DD/YYYY so that it reads 10/17/2011?

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Why don't you add that number of days directly to the DATE?

    Code:
    SELECT to_date('10/12/2011', 'MM/DD/YYYY') + 5 FROM dual;

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    I agree with Shammat.

    Anyway, to answer your question: use TO_DATE function:
    Code:
    SQL> select to_date(2455852, 'j') res from dual;
    
    RES
    ------------------------------
    17.10.2011
    In order to display the result in a desired format, apply TO_CHAR function with a format mask:
    Code:
    SQL> select to_char(to_date(2455852, 'j'), 'mm/dd/yyyy') res from dual;
    
    RES
    ------------------------------
    10/17/2011

Posting Permissions

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