MySQL FLOOR() Function

In MySQL, the FLOOR() function returns the largest integer value not greater than the specified number.

If you want to get the smallest integer value not less tha a specified number, use CEIL() or CEILING().

If you want to round a number to a specified number of decimal places, use the ROUND() function.

If you want to truncate decimal places by the number of digits, use the TRUNCATE() function.

FLOOR() Syntax

Here is the syntax of MySQL FLOOR() function:

FLOOR(number)

Parameters

number
Required. A number.

Return value

In MySQL, the FLOOR() function returns the largest integer value not greater than the specified number.

If the parameter is NULL, the FLOOR() function will return NULL.

FLOOR() Examples

SELECT
    FLOOR(123.123),
    FLOOR(123.789),
    FLOOR(123),
    FLOOR(-123.123),
    FLOOR(-123.789),
    FLOOR(-123),
    FLOOR(-100),
    FLOOR(NULL)\G

output

*************************** 1\. row ***************************
 FLOOR(123.123): 123
 FLOOR(123.789): 123
     FLOOR(123): 123
FLOOR(-123.123): -124
FLOOR(-123.789): -124
    FLOOR(-123): -123
    FLOOR(-100): -100
    FLOOR(NULL): NULL