Re: date_trunc() in a specific time zone

Paul A Jungwirth <pj@illuminatedcomputing.com>

From: Paul A Jungwirth <pj@illuminatedcomputing.com>
To: vik.fearing@2ndquadrant.com
Cc: Steve Crawford <scrawford@pinpointresearch.com>, andreas@proxel.se, pgsql-hackers@lists.postgresql.org
Date: 2018-10-29T16:50:07Z
Lists: pgsql-hackers
On Mon, Oct 29, 2018 at 9:40 AM Vik Fearing <vik.fearing@2ndquadrant.com> wrote:
> I don't necessarily want to
> display any dates, I could be grouping and aggregating.

I can attest that this patch would be really nice functionality to
have. Grouping is an often-overlooked case where timezones matter.
When grouping by day (e.g.), the timezone determines where you "slice
up" the timeline. I've needed this often enough that I have a personal
extension for it (https://github.com/pjungwir/pjpg) but that repo is a
bit sloppy, and I can't use it on managed services like RDS.

It would be nice to support both timestamptz and timestamp, with the
output matching whatever type you give as input. I know which to use
is controversial, but plain timestamp is the default in Ruby on Rails,
so people encounter it a lot.

Yours,
Paul


Commits

  1. Add a timezone-specific variant of date_trunc().