↑↓ 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

Reading PG 18current·documented in 7 of 27 versions, 14 to 20

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. 13 → 14 added

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