SQL> SET ECHO ON SQL> SET SERVEROUTPUT ON SQL> DECLARE 2 age DATE; 3 current_year NATURAL; 4 BEGIN 5 age := sysdate; 6 current_year := TO_NUMBER(TO_CHAR(age,'yy')); 7 DBMS_OUTPUT.PUT_LINE('current_year:'); 8 DBMS_OUTPUT.PUT_LINE(current_year); 9 END; 10 / current_year: 7 PL/SQL procedure successfully completed. SQL>
21.15.Convert to Number | ||||
21.15.1. | Use TO_NUMBER to assign value to NATURAL type variable | |||
21.15.2. | Get value from different parts of a date using TO_NUMBER function | |||
21.15.3. | Attempt to assign a single white space to a number. |