PL/SQL Trunc

The TRUNC (number) function returns n1 truncated to n2 decimal places.

The TRUNC (date) function returns date with the time portion of the day truncated to the unit specified by the format.

Trunc syntax

TRUNC( number, [ decimal_numbers ] ) 

TRUNC( date, [ format ] )

Trunc example

 
select trunc(987.167) from dual;	

Result: 987


select trunc(987.167,1) from dual;	

Result: 987.1


select trunc(987.167,2) from dual;	

Result: 987.16


select trunc(987.167,3) from dual;	

Result: 987.167


select trunc(to_date ('27-DEC-14'),'YEAR') from dual;	

Result: 01-JAN-2014 00:00:00


select trunc(to_date ('27-DEC-14'),'MONTH') from dual;		

Result: 01-DEC-2014 00:00:00