3 Replies Latest reply: Dec 9, 2013 2:17 AM by Vijetha RSS

    How do i extract year from a variable???

    Vijetha

      Hi all,

      I want to extract year from a parameter.

      I tried the following, i'm getting errors.

      When I executed the below code,

      SELECT TO_CHAR(:X_PRM_YR_END_DT,'YYYY') FROM dual;

      I got the following error.

      ORA-01722:invalid number

       

      When I executed the below code,

      SELECT TO_DATE(:X_PRM_YR_END_DT,'YYYY') FROM dual;

      SELECT to_char(TO_DATE(:X_PRM_YR_END_DT,'YYYY')) FROM dual;

      I got the following error.

      ORA-01830: date format end before converting entire input string

       

      When I executed the below code,

        SELECT extract(YEAR FROM :X_PRM_YR_END_DT) FROM dual;

        SELECT extract(YEAR FROM 1/11/2013) FROM dual;

      I got the following error.

      ORA-30076: invalid extract field for extract source

       

      How do i extract year from a variable???

      Help me plz

      Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production.