select open change scope Open full search

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

FUNCTIONS / DATE/TIME FUNCTIONS AND OPERATORS

Truncate to specified precision; see Section 9.9.2

Signatures & examples

date_trunc ( text, timestamp ) → timestamp
Truncate to specified precision; see Section 9.9.2
date_trunc('hour', timestamp '2001-02-16 20:38:40') → 2001-02-16 20:00:00
date_trunc ( text, timestamp with time zone, text ) → timestamp with time zone
Truncate to specified precision in the specified time zone; see Section 9.9.2
date_trunc('day', timestamptz '2001-02-16 20:38:40+00', 'Australia/Sydney') → 2001-02-16 13:00:00+00
date_trunc ( text, interval ) → interval
Truncate to specified precision; see Section 9.9.2
date_trunc('hour', interval '2 days 3 hours 40 minutes') → 2 days 03:00:00
date_trunc(field, source [, time_zone])
source is a value expression of type timestamp, timestamp with time zone, or interval. (Values of type date and time are cast automatically to timestamp or interval, respectively.) field selects to which precision to truncate the input value. The return value is likewise of type timestamp, timestamp with time zone, or interval, and it has all fields that are less significant than the selected one set to zero (or one, for day and month).
Version history 4
  1. PG 17 → 18changed
  2. PG 12 → 13changed
  3. PG 11 → 12changed
  4. PG 9.3 → 9.4changed

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