> This page location: Math Functions > TRUNC
> Full Neon documentation index: https://neon.com/docs/llms.txt

# PostgreSQL TRUNC() Function

**Info:** The TRUNC() function works the same in any PostgreSQL environment, so you can apply what you learn here to Postgres running anywhere. If you're an enterprise looking for managed cloud Postgres built for the AI era, [Lakebase](https://www.databricks.com/product/lakebase) delivers high performance, strong security, and deep integration with the Lakehouse. If you're a developer or startup who needs to ship and scale fast, [Neon](https://neon.com) gives you the best Postgres platform to build on.

The PostgreSQL `TRUNC()` function returns a number truncated to a whole number or truncated to the specified decimal places.

## Syntax

The following illustrates the syntax of the PostgreSQL `TRUNC()` function:

```sql
TRUNC(number [, precision])
```

## Arguments

The `TRUNC()` function accepts two arguments.

**1) `number`**

The `number` argument is a numeric value to be truncated

**2) `precision`**

The `precision` argument is an integer that indicates the number of decimal places.

If the `precision` argument is a positive integer, the `TRUNC()` function truncates digits to the right of the decimal point.

In case the `precision` is a negative integer, the `TRUNC()` function replaces digits to the left of the decimal point.

The precision argument is optional. If you don't specify it, it defaults to zero (0). In other words, the `number` is truncated to a whole number.

## Return value

The PostgreSQL `TRUNC()` function returns the same [numeric data type](../postgresql-tutorial/postgresql-numeric) as the first argument if the second argument is not specified. Otherwise, the function returns a numeric value if both arguments are used.

## Examples

### 1) Truncate to a whole number example

The following example uses the `TRUNC()` function to truncate a number to an integer:

```sql
SELECT
    TRUNC(10.6);
```

The result is:

```
10
```

### 2) Truncate to the specified decimal place

The following statement truncates a number to 2 decimal places:

```sql
 SELECT
    TRUNC(
        1.234,
        2
    );
```

Here is the result:

```
1.23
```

### 3) Truncate numbers with a negative second argument example

Consider the following example:

```sql
SELECT
    TRUNC(150.45,-2)
```

The second argument is -2, therefore, the `TRUNC()` function replaced the digits to the left of the decimal point that resulting in:

```
100
```

### 4) Truncate numbers returned by a query

See the following `film`, `film_category`, and `category` tables in the [sample database](../postgresql-getting-started/postgresql-sample-database):

![film film\_category category tables](https://neon.com/postgresqltutorial/film-film_category-category-tables.png)The following statement calculates the average rental rate by film category:

```sql
SELECT
    NAME,
    TRUNC(AVG( rental_rate ),2)
FROM
    film
INNER JOIN film_category
        USING(film_id)
INNER JOIN category
        USING(category_id)
GROUP BY
    NAME
ORDER BY NAME;
```

In this example, we used the `TRUNC()` function to truncate the average rentals to two decimal places.

The following picture illustrates the result:

![PostgreSQL TRUNC example](https://neon.com/postgresqltutorial/PostgreSQL-TRUNC-example.png)
In this tutorial, you have learned how to use the PostgreSQL `TRUNC()` function to truncate numbers.

---

## Related docs (Math Functions)

- [ABS](https://neon.com/postgresql/math-functions/abs)
- [CBRT](https://neon.com/postgresql/math-functions/cbrt)
- [CEIL](https://neon.com/postgresql/math-functions/ceil)
- [DEGREES](https://neon.com/postgresql/math-functions/degrees)
- [DIV](https://neon.com/postgresql/math-functions/div)
- [EXP](https://neon.com/postgresql/math-functions/exp)
- [FACTORIAL](https://neon.com/postgresql/math-functions/factorial)
- [FLOOR](https://neon.com/postgresql/math-functions/floor)
- [GCD](https://neon.com/postgresql/math-functions/gcd)
- [LCM](https://neon.com/postgresql/math-functions/lcm)
- [LN](https://neon.com/postgresql/math-functions/ln)
- [LOG](https://neon.com/postgresql/math-functions/log)
- [MOD](https://neon.com/postgresql/math-functions/mod)
- [MIN_SCALE](https://neon.com/postgresql/math-functions/min_scale)
- [PI](https://neon.com/postgresql/math-functions/pi-function)
- [POWER](https://neon.com/postgresql/math-functions/power)
- [RADIANS](https://neon.com/postgresql/math-functions/radians)
- [RANDOM](https://neon.com/postgresql/math-functions/random)
- [ROUND](https://neon.com/postgresql/math-functions/round)
- [SCALE](https://neon.com/postgresql/math-functions/scale)
- [SIGN](https://neon.com/postgresql/math-functions/sign)
- [SQRT](https://neon.com/postgresql/math-functions/sqrt)
- [TRIM_SCALE](https://neon.com/postgresql/math-functions/trim_scale)
- [WIDTH_BUCKET](https://neon.com/postgresql/math-functions/width_bucket)
