MariaDB: TRUNCATE Function
This MariaDB tutorial explains how to use the MariaDB TRUNCATE function with syntax and examples.
Description
The MariaDB TRUNCATE function returns a number truncated to a certain number of decimal places.
Syntax
The syntax for the TRUNCATE function in MariaDB is:
TRUNCATE( number, decimal_places )
Parameters or Arguments
- number
- The number to truncate.
- decimal_places
- The number of decimal places truncate to. This value must be a positive or negative integer.
Note
Applies To
The TRUNCATE function can be used in the following versions of MariaDB:
- MariaDB 10
Example
Let's look at some MariaDB TRUNCATE function examples and explore how to use the TRUNCATE function in MariaDB.
For example:
SELECT TRUNCATE(85.253, 0); Result: 85 SELECT TRUNCATE(85.253, 1); Result: 85.2 SELECT TRUNCATE(85.253, 2); Result: 85.25 SELECT TRUNCATE(85.253, -1); Result: 80 SELECT TRUNCATE(-85.253, 0); Result: -85
Advertisements