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

Bin input into specified interval aligned with specified origin; see Section 9.9.3

Signatures & examples

date_bin ( interval, timestamp, timestamp ) → timestamp
Bin input into specified interval aligned with specified origin; see Section 9.9.3
date_bin('15 minutes', timestamp '2001-02-16 20:38:40', timestamp '2001-02-16 20:05:00') → 2001-02-16 20:35:00
date_bin(stride, source, origin)
source is a value expression of type timestamp or timestamp with time zone. (Values of type date are cast automatically to timestamp.) stride is a value expression of type interval. The return value is likewise of type timestamp or timestamp with time zone, and it marks the beginning of the bin into which the source is placed.
Version history 1
  1. PG 13 → 14added

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