SQL>
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
2 v_sysdate DATE := SYSDATE;
3 v_date DATE;
4 v_char VARCHAR2(20);
5 BEGIN
6
7
8 DBMS_OUTPUT.PUT_LINE('Today''s Date: '||v_sysdate);
9
10
11 v_char := TO_CHAR(v_sysdate, 'DD:MM:YYYY HH24:MI:SS');
12 DBMS_OUTPUT.PUT_LINE('Display as CHARACTER DD:MM:YYYY HH24:MI:SS: '||v_char);
13
14
15 v_date := TO_DATE(v_char, 'DD:MM:YYYY HH24:MI:SS');
16 DBMS_OUTPUT.PUT_LINE('Convert back to DATE format: '||v_date);
17
18 END;
19 /
Today's Date: 03-JUN-07
Display as CHARACTER DD:MM:YYYY HH24:MI:SS: 03:06:2007 21:03:59
Convert back to DATE format: 03-JUN-07
PL/SQL procedure successfully completed.
SQL>