ts is converted to a UNIX timestamp split into millisecond and sub-millisecond parts.
Samples
Arguments
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
ts | TIMESTAMPTZ | - | ✔ | The timestamp used to return a UUIDv7 object |
Create a version 7 UUID from a Postgres timestamp
ts is converted to a UNIX timestamp split into millisecond and sub-millisecond parts.
SELECT to_uuidv7(ts)
FROM generate_series('2025-01-01:00:00:00'::timestamptz, '2025-01-01:00:00:03'::timestamptz, '1 microsecond'::interval) ts;
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
ts | TIMESTAMPTZ | - | ✔ | The timestamp used to return a UUIDv7 object |
Was this page helpful?