select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

FUNCTIONS / MATHEMATICAL FUNCTIONS AND OPERATORS

Truncates to integer (towards zero)

Signatures & examples

trunc ( numeric ) → numeric
Truncates to integer (towards zero)
trunc(42.8) → 42
trunc(-42.8) → -42
trunc ( double precision ) → double precision
Truncates to integer (towards zero)
trunc(42.8) → 42
trunc(-42.8) → -42
trunc ( v numeric, s integer ) → numeric
Truncates v to s decimal places
trunc(42.4382, 2) → 42.43
trunc ( macaddr ) → macaddr
Sets the last 3 bytes of the address to zero. The remaining prefix can be associated with a particular manufacturer (using data not included in PostgreSQL).
trunc(macaddr '12:34:56:78:90:ab') → 12:34:56:00:00:00
trunc ( macaddr8 ) → macaddr8
Sets the last 5 bytes of the address to zero. The remaining prefix can be associated with a particular manufacturer (using data not included in PostgreSQL).
trunc(macaddr8 '12:34:56:78:90:ab:cd:ef') → 12:34:56:00:00:00:00:00
Version history 2
  1. PG 12 → 13changed
  2. PG 9.6 → 10changed

Definition snapshot: 2026-09-14T13:14:25.684213+00:00@99e6866c · English manual source