Re: [PATCH] Generate random dates/times in a specified range

From: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Damien Clochard <damien(at)dalibo(dot)info>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Generate random dates/times in a specified range
Date: 2025-07-15 14:59:38
Message-ID: CAKAnmmJb54X65PjeccHgrec_mCiubHrjTS7LtCpwOtxscR21eA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 14, 2025 at 3:21 AM Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
wrote:

> But it's completely trivial to emulate random(min_date, max_date), just by
> doing
>
> min_date + random(0, max_date - min_date)
>
> Is it really worth adding a core function for that?
>

Yes, I think it is. It is also trivial to get a random int from 50 to 100
with

50 + floor(random() * 51)

but random(50,100) is so much nicer.

Cheers,
Greg

--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Junwang Zhao 2025-07-15 15:06:11 remove WITHOUT OIDS syntax for v19
Previous Message Nathan Bossart 2025-07-15 14:57:16 Re: TOAST table vacuum truncation parameter inheritance bug (?) in autovacuum