Skip to main content
Version: V1.0.0

TRUNCATE

Syntax

TRUNCATE(X,D)

Description

Returns the result of X with D decimal places. If D is 0, it returns the integer part of X. If D is negative, it sets the D digits to the left of the decimal point in X to 0.

Examples

SELECT TRUNCATE(3.27,1);
+------------------+
| TRUNCATE(3.27,1) |
+------------------+
| 3.2 |
+------------------+
1 row in set (0.001 sec)

SELECT TRUNCATE(3.27,0);
+------------------+
| TRUNCATE(3.27,0) |
+------------------+
| 3 |
+------------------+
1 row in set (0.001 sec)

SELECT TRUNCATE(3.27,-1);
+-------------------+
| TRUNCATE(3.27,-1) |
+-------------------+
| 0 |
+-------------------+
1 row in set (0.001 sec)