Postgresql Floor Function

PostgreSQL: floor Function

In this PostgreSQL post explains how to use the PostgreSQL floor function with syntax and examples.

Description

The PostgreSQL floor function returns the largest integer value that is equal to or less than a number.

Syntax

The syntax for the floor function in PostgreSQL is:

floor( number )

Parameters or Arguments

number

The value used to find the largest integer value.

Note

Applies To

The floor function can be used in the following versions of PostgreSQL:

  • PostgreSQL 9.4, PostgreSQL 9.3, PostgreSQL 9.2, PostgreSQL 9.1, PostgreSQL 9.0, PostgreSQL 8.4

Example

Let's look at some PostgreSQL floor function examples and explore how to use the floor function in PostgreSQL.

For example:

postgres=# SELECT floor(32.65);
 floor
-------

    32
(1 row)

postgres=# SELECT floor(32.1);
 floor
-------

    32
(1 row)

postgres=# SELECT floor(32);
 floor
-------

    32
(1 row)

postgres=# SELECT floor(-32.65);
 floor
-------

   -33
(1 row)

postgres=# SELECT floor(-32.1);
 floor
-------

   -33
(1 row)

postgres=# SELECT floor(-32);
 floor
-------

   -32
(1 row)