Numbers

TRUNC

Drops the fractional part of a number without rounding.

Syntax

TRUNC(<number>)
TRUNC(<number>, <decimals>)

It simply cuts off the extra digits: 4.9 becomes 4, and -4.9 becomes -4 — always towards zero. The second argument keeps the number of decimal places you need, like ROUND, but without rounding.

Data for the examples

orders

idcreated_atamount
12026-07-03 10:15:00120.50
22026-07-28 18:40:0080.25
32026-08-09 09:05:00199.99
42026-08-21 14:30:0045.00
52026-09-02 11:00:0064.75

These tables already exist in the sandbox — the examples below use them. Want to try this in your own database? Copy the SQL.

Drop the fractional part
SELECT TRUNC(4.9) AS positive,
TRUNC(-4.9) AS negative,
TRUNC(19.857, 2) AS two_digits;
positivenegativetwo_digits
4-419.85
ROUND and TRUNC side by side
SELECT id, amount,
ROUND(amount) AS rounded,
TRUNC(amount) AS truncated
FROM orders;
idamountroundedtruncated
1120.50121120
280.258080
3199.99200199
445.004545
564.756564

120.50 rounds to 121 but truncates to 120.

Watch out

Don't confuse it with FLOOR for negative numbers: TRUNC(-4.9) gives -4, while FLOOR(-4.9) gives -5.

TRUNC(x, 2) exists only for numeric: for double precision you'll get function trunc(double precision, integer) does not exist. Cast the type: TRUNC(x::numeric, 2).

In PostgreSQL, TRUNC doesn't truncate dates — that's a habit from Oracle. To cut a date down to the month or day, use DATE_TRUNC.

Related functions