What is the difference between Ceiling and floor functions?

Ceiling and Floor are the basic mathematical functions which returns largest previous or smallest next integer for the given numeric value/an expression.

Ceiling(): This function returns the greater than or equal to the numeric value/an expression provided.

Ex:

—————————–
SELECT ceiling(15.3)
—————————–
Result: 16
—————————–
SELECT ceiling(15.9)
—————————–
Result: 16
—————————–

Floor(): This function returns the less than or equal to the numeric value/an expression provided.

Ex:

—————————–
SELECT floor(15.3)
—————————–
Result: 15
—————————–
SELECT floor(15.9)
—————————–
Result: 15
—————————–

Happy Reading :)

Reference: MSDN

Leave a Reply

Your email address will not be published. Required fields are marked *