TRUNC (Azure Cosmos DB)

Returns a numeric value, truncated to the closest integer value.

Syntax

TRUNC(<numeric_expr>)  

Arguments

numeric_expr
Is a numeric expression.

Return types

Returns a numeric expression.

Examples

The following example truncates the following positive and negative numbers to the nearest integer value.

SELECT TRUNC(2.4) AS t1, TRUNC(2.6) AS t2, TRUNC(2.5) AS t3, TRUNC(-2.4) AS t4, TRUNC(-2.6) AS t5  

Here is the result set.

[{t1: 2, t2: 2, t3: 2, t4: -2, t5: -2}]  

Remarks

This system function will benefit from a range index.

Next steps