Hello,
As I am involved in the PostgreSQL Anonymizer extension, I found that
the random(min,max) functions introduced recently are very useful to
generate synthetic data or define a masking policy.
I decided to submit a similar set of functions for random dates and
times.
So this adds 5 new variants of the random() function:
random(min date, max date) returns date
random(min time, max time) returns time
random(min time, max time, zone text) returns timetz
random(min timestamp, max timestamp) returns timestamp
random(min timestamptz, max timestamptz) returns timestamptz
Each one returns a random date/time value t in the range min <= t <=
max.
For the timetz function, a third parameter is required to define the
timezone.
However if the value is an empty string, the session timezone is used.
These functions all rely on the pg_prng_int64_range function developped
in
PG 17 for the random(bigint,bigint) function.
Regards,
--
Damien Clochard