TRUNCATE
All functions > MATH > TRUNCATE
Truncates a number towards zero (removes the fractional part).
Syntax
TRUNCATE(expr)
sql
Arguments
Parameter | Type | Required | Description |
---|---|---|---|
number | DOUBLE | Yes | The number to truncate |
Returns
BIGINT - Integer result after truncation
Notes
- Removes the fractional part, rounding towards zero
TRUNCATE(2.9) = 2
,TRUNCATE(-2.9) = -2
- Different from FLOOR for negative numbers
TRUNCATE(-2.9) = -2
vsFLOOR(-2.9) = -3
- Returns NULL if the input is NULL
- Also known as "truncation" or "chopping"