## Syntax
```mermaid
%%{init: {
'theme': 'base',
'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
'themeVariables': {
'fontSize': '11px',
'fontFamily': 'Arial'
}
}}%%
flowchart LR
Start((START)) --> TRUNC[TRUNC]:::quoted
TRUNC --> End((END))
```
## Purpose
The `TRUNC` SQL function calculates the integral part of a number. Unless a number of decimals is defined, in which case it calculates to the integer with the number of decimals or date with the number of positions. See also: [[CEIL]], [[FLOOR]] and [[ROUND]].
Parameters:
- Input: a number or datetime to truncate.
- Decimals (optional): a number to specify how many decimals it may truncate 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.
Returns: the truncated input.
The time positions are:
- 2: minute
- 1: hour
- 0: day
- -1: month
- -2: year
## Examples
The following example retrieves the truncated value of -15.32:
```sql
select trunc(-15.32)
--------
-15
```
The following example retrieves the truncated value of -15.32 with 1 positions:
```sql
select trunc(-15.32, 1)
--------
-15.3
```
The following example retrieves the truncated value of -15.32 with -1 positions:
```sql
select trunc(-15.32, -1)
--------
-10
```
The following example retrieves the truncated value of the date 2026-05-19 13:20:34:
```sql
select to_char(trunc(to_date('20260519132034', 'YYYYMMDDHH24MISS')), 'YYYYMMDDHH24MISS')
----------------
20260519000000
```
The following example retrieves the truncated value of the date 2026-05-19 13:20:34 with 1 time positions:
```sql
select to_char(trunc(to_date('20260519132034', 'YYYYMMDDHH24MISS'), 1), 'YYYYMMDDHH24MISS')
----------------
20260519130000
```