FLOOR Function
FLOOR ( numeric_expression )
Description
Returns the largest integer less than or equal to the specified numeric expression.
Parameters
numeric_expression: Required. A numeric data type (including date and time types, but notmoneyorsmallmoney) that is a numeric expression.
Return Value
- Returns the largest integer less than or equal to the
numeric_expression. The return type is the same as the inputnumeric_expression's data type, except that it will be one of the integer types.
Examples
Example 1: Using FLOOR with positive numbers
SELECT FLOOR(123.45) AS FloorValue;
-- Result: 123
Example 2: Using FLOOR with negative numbers
SELECT FLOOR(-123.45) AS FloorValue;
-- Result: -124
Example 3: Using FLOOR with date/time values
SELECT FLOOR('2023-10-27 14:30:00.123') AS FloorDateTime;
-- Result: 2023-10-27 00:00:00.000
Example 4: Using FLOOR with a table column
-- Assuming a table named 'Products' with a 'Price' column (DECIMAL(10,2))
SELECT
ProductName,
Price,
FLOOR(Price) AS FloorPrice
FROM
Products;