invantive documentationpart of invantive cloud
Invantive Support ForumsLog In / Sign Up

CEIL

Syntax

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

Purpose

The CEIL SQL function rounds the input to the largest following integer. In case a number of decimals is defined, in which case it rounds to the largest integer number to the indicated number of decimals or date with the number of positions.

See also FLOOR, TRUNC and ROUND.

Parameters:

  • Input (decimal or datetime): value to retrieve ceiling value for.
  • Decimals (optional, decimal): a number to specify how many decimals it may ceil 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 ceiling of the input as datetime (for input datetime) or decimal for numbers.

datetime Only

The possible value for decimals on a datetime are:

  • 2: minute
  • 1: hour
  • 0: day
  • -1: month
  • -2: year

Examples

The following example retrieves the ceiling of -15.32:

select ceil(-15.32)

--------
-15

The following example retrieves the ceiling of -15.32 with 1 positions:

select ceil(-15.32, 1)

--------
-15.3

The following example retrieves the ceiling of -15.32 with -1 positions:

select ceil(-15.32, -1)

--------
-10

The following example retrieves the ceiling of the date 2026-05-19 13:20:34:

select to_char(ceil(to_date('20260519132034', 'YYYYMMDDHH24MISS')), 'YYYYMMDDHH24MISS')

----------------
20260520000000

The following example retrieves the ceiling of the date 2026-05-19 13:20:34 with 1 time positions:

select to_char(ceil(to_date('20260519132034', 'YYYYMMDDHH24MISS'), 1), 'YYYYMMDDHH24MISS')

----------------
20260519140000