Data implicit conversion examples: from char to date : Data Type Convert « PL SQL « Oracle PL / SQL






Data implicit conversion examples: from char to date

SQL>
SQL> -- Implicit conversion examples.
SQL>
SQL> SET SERVEROUTPUT ON
SQL>
SQL> DECLARE
  2     d1    DATE;
  3     cd1   VARCHAR2(10);
  4     cd2   VARCHAR2(10);
  5  BEGIN
  6     cd1 := '15-Nov-61';
  7     -- Now assign the string to a date variable.    The conversion is implicit.
  8     d1 := cd1;
  9     -- Now assign that date variable to another string.
 10     -- Again the conversion is implicit, but this time the conversion is
 11     -- from a date to a string.
 12     cd2 := d1;
 13     -- Display the two character strings to show that they are the same.
 14     DBMS_OUTPUT.PUT_LINE('CD1 = ' || cd1);
 15     DBMS_OUTPUT.PUT_LINE('CD2 = ' || cd2);
 16
 17  END;
 18  /
CD1 = 15-Nov-61
CD2 = 15-NOV-61

PL/SQL procedure successfully completed.

SQL>

           
       








Related examples in the same category

1.Convert char to date: TO_DATE('January 01, 2000','Month DD, YYYY')
2.Convert number to char
3.Converting number to character formatted as a numeric string
4.Convert char to number
5.Converting VARCHAR2 percentage data to a decimal equivalent
6.Convert date to char, and char to date with various formats
7.Convert char to number and number to char with various formats
8.Data implicit conversion examples: from char to number
9.Expressing your work in scientific notation with TO_CHAR()