Use TO_CHAR in PL/SQL : Date Type Convert « PL SQL Data Types « Oracle PL/SQL Tutorial






SQL>
SQL> SET ECHO ON
SQL>
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
  2    payment_due_date  DATE;
  3  BEGIN
  4    payment_due_date := TRUNC(SYSDATE);
  5
  6    DBMS_OUTPUT.PUT_LINE('Today is ' || TO_CHAR(SYSDATE,'dd-Mon-yyyy'));
  7    DBMS_OUTPUT.PUT_LINE('Payment is due on ' || TO_CHAR(payment_due_date,'dd-Mon-yyyy'));
  8
  9  END;
 10  /
Today is 02-Jun-2007
Payment is due on 02-Jun-2007

PL/SQL procedure successfully completed.

SQL>
SQL>








21.11.Date Type Convert
21.11.1.Use TO_CHAR in PL/SQL
21.11.2.Assign the string to a date variable. The conversion is implicit.
21.11.3.Assign that date variable to another string
21.11.4.Explicit declaration of format mask
21.11.5.Explicit declaration of format mask in where clause
21.11.6.Determine and display years and months