SQL Server FLOOR() Function

The FLOOR() function in SQL Server rounds a number *down* to the nearest integer.



FLOOR(): Definition and Usage

This function is useful when you need to work with whole numbers and want to discard any fractional part of a number. It always rounds towards negative infinity.

Related Functions

For related functionality, consider also looking at the CEILING() function (which rounds *up* to the nearest integer) and the ROUND() function (which rounds to a specified number of decimal places).

Syntax

Syntax

FLOOR(number)
      

Parameter Values

Parameter Description
number The numeric value you want to round down. This is required.

Examples

Rounding a Positive Number Down

This example shows how FLOOR() rounds 25.75 down to 25.

Syntax

SELECT FLOOR(25.75) AS FloorValue;
      
Output

25
      

Rounding a Whole Number Down

Even though it's already an integer, FLOOR() returns the same value.

Syntax

SELECT FLOOR(25) AS FloorValue;
      
Output

25
      

Rounding a Negative Number Down

For negative numbers, FLOOR() rounds towards negative infinity.

Syntax

SELECT FLOOR(-13.5) AS FloorValue;
      
Output

-14
      

Technical Details

The FLOOR() function is available in:

  • SQL Server (starting with version 2008)
  • Azure SQL Data Warehouse
  • Parallel Data Warehouse