Tip of the Day : Example Uses of the FLOOR Mathematical Function

Welcome to SQL Server Helper !!!

This site is intended for those who are beginning to use SQL Server as part of their day-to-day activities.  You will find in this site a collection of useful functions, triggers, stored procedures and tips and tricks related to SQL Server.

Should you have any comments or questions regarding this site or if you want to ask SQL Server-related questions, e-mail us here.

We hope we are able to help and we are glad to help!!!

SQL Server Tip of the Day - February 13, 2026

Example Uses of the FLOOR Mathematical Function

The FLOOR mathematical function returns the largest integer less than or equal to the specified numeric expression.  The syntax of the FLOOR mathematical function is as follows:

FLOOR ( < numeric_expression > )

The < numeric_expression > parameter is an expression of the exact numeric or approximate numeric data type category, except for the bit data type.  The data type returned by the FLOOR mathematical function is the same data type as the parameter passed to it.

Usage #1 : Determine if a Float or Decimal is an Integer

DECLARE @Input		FLOAT

SET @Input = 123.456

IF @Input = FLOOR(@Input)
    PRINT '@Input is an Integer'
ELSE
    PRINT '@Input is NOT an Integer'
	
SET @Input = 1234.000
IF @Input = FLOOR(@Input)
    PRINT '@Input is an Integer'
ELSE
    PRINT '@Input is NOT an Integer'
GO

Usage #2 : Get the Decimal Part of a Float or Decimal Number

DECLARE @Input		DECIMAL(10, 4)

SET @Input = 12345.6789

SELECT @Input - FLOOR(@Input) AS [DecimalPart]
GO

Usage #3 : Get the Date Part of a Date/Time Value

SELECT CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)

Usage #4 : Get the Time Part of a Date/Time Value

SELECT GETDATE(), CAST(CAST(GETDATE() AS FLOAT) - FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)

SQL Server 2012

SQL Server 2008

User-Defined Functions

Date Functions

A collection of useful user-defined functions that deal with dates.

String Functions

A collection of useful user-defined functions that deal with strings (varchar/char/nvarchar/nchar).

Tree Functions

A collection of useful user-defined functions that deal with tree or hierarchical design structures.

Table-Valued Functions

A collection of useful table-valued user-defined functions that can be used to join with other tables.

SQL Server Built-in Functions

A reference to all built-in functions available within SQL Server grouped into categories.

Tips and Tricks

A collection of useful SQL Server-related tips and tricks:

SQL Server Error Messages

A list of SQL Server error messages and for certain error messages, discusses ways on how to solve the error or work around them:

Frequently Asked Questions