PL/SQL Trunc

Oracle PL/SQL Trunc Function

The Trunc function(numbers) returns the 1st argument truncated by the number of decimal places specified in the 2nd argument.

The Trunc function(dates)) returns a date truncated to a specific unit of measure.

The Trunc Function syntax:

trunc( number, [ decimal_numbers ] )

trunc( date, [ format ] )

Example Trunc numbers

Select trunc(657.143) From dual; 
657

Select trunc(657.143,0) From dual;
657

Select trunc(657.143,2) From dual;
657.14

Select trunc(-657.143,2) From dual;
-657.14

Select trunc(-657.143, -1) From dual;
-650

Select trunc(-657.143, -2) From dual;
-600

Select trunc(-657.143, -3) From dual;;
0

Example Trunc dates

Select trunc(to_date ('17-DEC-09'),'YEAR') From dual; 
1/1/2009

Select trunc(to_date ('21-SEP-09'),'Q') From dual;
7/1/2009

Select trunc(to_date ('22-OCT-09'),'MONTH') From dual;
10/1/2009

Select trunc(to_date ('22-OCT-09'),'DDD') From dual;
10/22/2009

Select trunc(to_date ('22-MAY-09'),'DAY') From dual;
5/17/2009