Reference Guide > TDV Support for SQL Functions > TDV-Supported Convert Functions > TRUNC (for numbers)
 
TRUNC (for numbers)
The TRUNC function returns the integer portion of an expression, or, using the optional second argument, returns the expression with a specified number of decimal places. TRUNC does not take the sign of the expression into account; in other words, the decimal portion of both negative and positive expressions trend toward zero.
Syntax
TRUNC (expression, [decimal_places])
Remarks
The input argument expression represents the number to truncate and a NUMERIC or date/time data type as follows:
If the first argument is a numeric expression (DECIMAL, FLOAT, INTEGER, or STRING), the second argument is the number of decimal places to truncate to.
If the second argument is greater than the number of decimal places of the first argument, zeros are added to the right of the last significant digit.
If the second argument is not present, the function returns the integer portion of the expression.
The output is the same data type as the first input value.
If either input is NULL, the output is NULL.
Examples
SELECT TRUNC(5.234);
 
This returns 5.
SELECT TRUNC(5.234, 2);
 
This returns 5.23.
SELECT TRUNC(5.234, 5);
 
This returns 5.23400.