Re: Forcing INTERVAL days display, even if the interval is less than one day

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Forcing INTERVAL days display, even if the interval is less than one day
Date: 2024-05-07 16:57:33
Message-ID: 4130719.1715101053@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ron Johnson <ronljohnsonjr(at)gmail(dot)com> writes:
> PG 9.6.24, if relevant. (Hopefully we're migrating next month.)
> Displaying how long ago a date was is easy, but interval casts "helpfully"
> suppress "X days ago" if the interval is less than one day ago.

> How do I make it display "days ago", even when days ago is zero?
> Explicitly casting "day to second" didn't work.

to_char() could be your friend here.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2024-05-07 17:04:44 Re: Question regarding how databases support atomicity
Previous Message Siddharth Jain 2024-05-07 16:48:38 Re: Question regarding how databases support atomicity