Re: ago(interval) → timestamptz

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Florents Tselai <florents(dot)tselai(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ago(interval) → timestamptz
Date: 2025-11-04 05:55:47
Message-ID: 8bf621c358b84f62e2f51f0ab2fb0758da722e49.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 2025-11-03 at 22:36 +0100, Florents Tselai wrote:
> I realize this will get some "you can easily implement this yourself” pushback,
> But I keep seeing and writing a lot of WHERE ts > now() - interval '1 day' expressions.

You can easily implement this yourself...
Also, there already is something similar in the shape of 'yesterday'::timestamptz.
Moreover, a good percentage of the users would instead need ago(interval) -> timestamp.

So I'd say that the added value is marginal, and I personally find

current_timestamp - INTERVAL '1' DAY

more readable and more SQL standard compliant than

ago('1 day')

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2025-11-04 06:02:14 Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
Previous Message Michael Paquier 2025-11-04 05:38:01 Re: BRIN autosummarization lacking a snapshot