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

From: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
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 19:47:14
Message-ID: CAKAnmm+C-8Hr8=3srR9tNbDrMnQG_Qwc+cgvFT9NJHuhWcyo8Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Could just use a CASE for that particular case:

CASE WHEN now()-latest_vacuum < '1 day'
THEN '0 days '
ELSE '' END
|| DATE_TRUNC('second', now()-latest_vacuum) AS vacuumed_ago

Cheers,
Greg

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mike Jarmy 2024-05-07 21:04:27 Using GIN Index to see if a nested key exists in JSONB
Previous Message Adrian Klaver 2024-05-07 17:15:23 Re: Question regarding how databases support atomicity