FLOOR() and CEILING() Function in SQL Server

1. FLOOR() Function :
The FLOOR() function returns the largest integer value which is less than or equal to a number.

Syntax :

FLOOR(number)

Parameter : Required. A numeric value.
number : It is a numeric value.
Returns : It returns the integer value.

Example-1 :
When the argument holds a positive number.

SELECT FLOOR(21.53);

Output :



21



Example-2 :
When the argument holds a negative number.

SELECT FLOOR(-21.53);

Output :

-22


2. CEILING() Function :
The CEILING() function returns the smallest integer value which is greater than or equal to a number.

Syntax :

CEILING(number)

Parameter : Required. A numeric value.
number : It is a numeric value.
Returns : It returns the integer value.

Example-1 :
When the argument holds a positive number.

SELECT CEILING(21.53);

Output :

22



Example-2 :
When the argument holds a negative number.

SELECT CEILING(-21.53);

Output :

-21
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.