Oracle PL/SQL/PL SQL/Date Convert

Материал из SQL эксперт
Перейти к: навигация, поиск

Converting DATE to spelled-out character format

SQL> -- Converting DATE to spelled-out character format.
SQL> DECLARE
  2        myDate DATE := TO_DATE("06112067BC","MMDDYYYYBC");
  3        myString VARCHAR2(100);
  4  BEGIN
  5        myString := TO_CHAR(myDate,"MMDDSYYYY");
  6        DBMS_OUTPUT.PUT_LINE("The converted date is: " || myString);
  7  END;
  8  /
The converted date is: 0611-2067
PL/SQL procedure successfully completed.
SQL>



Using TO_DATE within PL/SQL

SQL>
SQL> -- Using TO_DATE within PL/SQL.
SQL> DECLARE
  2        v_Convert_Date DATE;
  3  BEGIN
  4        v_Convert_Date := TO_DATE("061167","MMDDYY");
  5        DBMS_OUTPUT.PUT_LINE("The converted date is: " || v_Convert_Date);
  6  END;
  7  /
The converted date is: 11-JUN-67
PL/SQL procedure successfully completed.
SQL>