SQLite trunc() Function

The SQLite trunc() function returns the integer part of the specified number.

The trunc() function are different from ceil() and floor():

  • The ceil() function returns the smallest integer value greater than or equal to the number specified by the parameter.
  • The floor() function returns the largest integer value less than or equal to the number specified by the parameter.

Syntax

Here is the syntax of the SQLite trunc() function:

trunc(numeric_value)

Parameters

numeric_value

Required. A number, it can be positive, negative, or zero, it can be an integer or a decimal.

Return value

The SQLite trunc() function returns the integer part of the specified number.

The SQLite trunc() function will return NULL if the parameter is NULL or a non number.

Examples

This example shows the basic usage of the SQLite trunc() function:

SELECT
    trunc(10.11),
    trunc(10.99);
trunc(10.11) = 10.0
trunc(10.99) = 10.0