---
title: "FLOOR"
description: "The FLOOR SQL function rounds the input to the smallest preceding integer."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/floor
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/floor
updated: 2026-08-09T00:00:00Z
license: https://documentation.invantive.eu/en/
---

## Syntax
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> FLOOR[FLOOR]:::quoted
    FLOOR --> End((END))
```

## Purpose
The `FLOOR` SQL function rounds the input to the smallest preceding integer. Unless a number of decimals is defined, in which case it rounds to the smallest integer with the number of decimals or date with the number of positions.

See also [[CEIL]], [[TRUNC]] and [[ROUND]].

Parameters:
- Input (`decimal` or `datetime`): value to calculate floor of.
- Decimals (optional, `decimal`): a number to specify how many decimals it may floor to in case of a number. In case of a `datetime`, it reflects the number of time positions, ranging from -2 for years to 2 for minutes. Defaults to `0`.

Returns: the floor of the input as `datetime` (for input `datetime`) or `decimal` for numbers.

The time positions are:
- 2: minute
- 1: hour
- 0: day
- -1: month
- -2: year

## Examples
The following example retrieves the floor of -15.32:
```sql
select floor(-15.32)

--------
-16
```
The following example retrieves the floor of -15.32 with 1 positions:
```sql
select floor(-15.32, 1)

--------
-15.4
```
The following example retrieves the floor of -15.32 with -1 positions:
```sql
select floor(-15.32, -1)

--------
-20
```
The following example retrieves the floor of the date 2026-05-19 13:20:34:
```sql
select to_char(floor(to_date('20260519132034', 'YYYYMMDDHH24MISS')), 'YYYYMMDDHH24MISS')

----------------
20260519000000
```
The following example retrieves the floor of the date 2026-05-19 13:20:34 with 1 time positions:
```sql
select to_char(floor(to_date('20260519132034', 'YYYYMMDDHH24MISS'), 1), 'YYYYMMDDHH24MISS')

----------------
20260519130000
```

