ROUND(date_in_1,'CC') : ROUND « Date Timestamp Functions « Oracle PL/SQL Tutorial






SQL>
SQL> DECLARE
  2     date_in_1 DATE := TO_DATE('24-Feb-2002','DD-MON-YYYY');
  3     date_in_2 DATE := TO_DATE('24-Feb-1902','DD-MON-YYYY');
  4     date_in_3 DATE := TO_DATE('24-Feb-2002 05:36:00 PM','DD-MON-YYYY HH:MI:SS AM');
  5
  6     round_1 DATE;
  7     round_2 DATE;
  8     round_3 DATE;
  9
 10  BEGIN
 11     round_1 := ROUND(date_in_1,'CC');
 12     round_2 := ROUND(date_in_2,'CC');
 13     round_3 := ROUND(date_in_3,'HH');
 14
 15     DBMS_OUTPUT.PUT_LINE(TO_CHAR(round_1,'DD-MON-YYYY HH:MI:SS AM'));
 16     DBMS_OUTPUT.PUT_LINE(TO_CHAR(round_2,'DD-MON-YYYY HH:MI:SS AM'));
 17     DBMS_OUTPUT.PUT_LINE(TO_CHAR(round_3,'DD-MON-YYYY HH:MI:SS AM'));
 18  END;
 19  /

PL/SQL procedure successfully completed.

SQL>








13.15.ROUND
13.15.1.The ROUND Function
13.15.2.Datetime Formatting Parameters for ROUND(x[, unit])
13.15.3.ROUND(x[, unit]) : round x. By default, x is rounded to the beginning of the nearest day
13.15.4.Round date to day
13.15.5.Rounds May 25, 2005, to the first day in the nearest month
13.15.6.Rounding to the Nearest Minute
13.15.7.ROUND(date_in_1,'CC')
13.15.8.Round result from months_between