SQL Server FLOOR() Function

In SQL Server, the FLOOR() function is used to return the largest integer that is less than or equal to a given numeric expression. The concept of this function in mathematics is called floor.

Syntax

FLOOR(numeric_expression)

Usage

The FLOOR() function is commonly used when it is necessary to convert a floating-point number or decimal to an integer, such as when processing currency amounts. The function simply truncates the decimal portion and returns the integer portion.

Examples

Here are two examples of using the FLOOR() function:

Example 1

SELECT FLOOR(3.14)

Output:

3

Example 2

SELECT FLOOR(6.789)

Output:

6

Conclusion

The FLOOR() function is one of the commonly used numeric functions in SQL Server, used to round a floating-point number or decimal down to an integer. Note that the FLOOR() function returns an integer, so if decimal places need to be retained, other functions such as the ROUND() or CAST() function can be used.