TRUNCATE function

The TRUNCATE numeric function truncates a supplied decimal number a specified number of places.

SYNTAX

If precision is positive, the result of the TRUNCATE function is source_number truncated to precision places right of the decimal point. If precision is negative, the result is source_number truncated to the absolute value of precision places to the left of the decimal point.

source_number can be any built-in numeric data type. precision must evaluate to an INTEGER. The result is of the same data type as source_number. If any parameter is NULL, the result is NULL.

For example:
TRUNCATE(27.75, 2)
returns 27.75
TRUNCATE(27.75, 1)
returns 27.7
TRUNCATE(27.75, 0)
returns 27.0
TRUNCATE(27.75, -1)
returns 20.0

If possible, the scale is changed to the given value. If the result cannot be represented within the given scale, it is INF.

Related concepts
ESQL overview
Related tasks
Developing ESQL
Related reference
Syntax diagrams: available types
ESQL numeric functions