1 Reply Latest reply: Oct 6, 2012 4:43 PM by EJP RSS

    Conflict between to_date and to_char function

    966610
      Some confusion regarding to_date and to_char functions:

      SELECT TO_CHAR(TO_DATE(TO_CHAR(TO_DATE('23-MAY-2001','DD-MON-YYYY'),'DD-MON-YY'),'DD-MON-YY'),'DD-MON-YYYY') FROM DUAL;

      Ouput: 23-MAY-2001

      SELECT TO_CHAR(TO_DATE(TO_CHAR(TO_DATE('23-MAY-1901','DD-MON-YYYY'),'DD-MON-YY'),'DD-MON-YY'),'DD-MON-YYYY') FROM DUAL;

      The output is same as : 23-MAY-2001

      So, I changed it RR format:

      SELECT TO_CHAR(TO_DATE(TO_CHAR(TO_DATE('23-MAY-1901','DD-MON-RRRR'),'DD-MON-RR'),'DD-MON-RR'),'DD-MON-RRRR') FROM DUAL;

      Again the output is same only:
      23-MAY-2001