tech on the net

Oracle/PLSQL: Trunc Function (with numbers)

In Oracle/PLSQL, the trunc function returns a number truncated to a certain number of decimal places.

Syntax

The syntax for the trunc function is:

trunc( number, [ decimal_places ] )

number is the number to truncate.

decimal_places is the number of decimal places to truncate to. This value must be an integer. If this parameter is omitted, the trunc function will truncate the number to 0 decimal places.

Applies To

For Example

trunc(125.815) would return 125
trunc(125.815, 0) would return 125
trunc(125.815, 1) would return 125.8
trunc(125.815, 2) would return 125.81
trunc(125.815, 3) would return 125.815
trunc(-125.815, 2) would return -125.81
trunc(125.815, -1) would return 120
trunc(125.815, -2) would return 100
trunc(125.815, -3) would return 0