SQL>
SQL> DECLARE
2 date_in DATE := TO_DATE('24-Feb-2002 05:36:00 PM'
3 ,'DD-MON-YYYY HH:MI:SS AM');
4 trunc_to_year DATE;
5 trunc_to_month DATE;
6
7 BEGIN
8 trunc_to_year := TRUNC(date_in,'YYYY');
9 trunc_to_month := TRUNC(date_in,'MM');
10
11 DBMS_OUTPUT.PUT_LINE(
12 TO_CHAR(trunc_to_year, 'DD-MON-YYYY HH:MI:SS AM'));
13 DBMS_OUTPUT.PUT_LINE(
14 TO_CHAR(trunc_to_month,'DD-MON-YYYY HH:MI:SS AM'));
15 END;
16 /
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL>
|