Re: [PATCH] Generate random dates/times in a specified range - Mailing list pgsql-hackers

From Greg Sabino Mullane
Subject Re: [PATCH] Generate random dates/times in a specified range
Date
Msg-id CAKAnmmJb54X65PjeccHgrec_mCiubHrjTS7LtCpwOtxscR21eA@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] Generate random dates/times in a specified range  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Responses Re: [PATCH] Generate random dates/times in a specified range
List pgsql-hackers
On Mon, Jul 14, 2025 at 3:21 AM Dean Rasheed <dean.a.rasheed@gmail.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

--
Enterprise Postgres Software Products & Tech Support

pgsql-hackers by date:

Previous
From: Nathan Bossart
Date:
Subject: Re: TOAST table vacuum truncation parameter inheritance bug (?) in autovacuum
Next
From: Junwang Zhao
Date:
Subject: remove WITHOUT OIDS syntax for v19