PostgreSQL 18 reference · UUID Functions

PostgreSQL UUID_EXTRACT_TIMESTAMP() Function

Return the creation time stored inside a version 1 or 7 UUID, or NULL for other versions. Added in PostgreSQL 17.

PostgreSQL 18 Since 17

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

uuid_extract_timestamp(uuid)  |  uuid_extract_version(uuid)

Parameters

ParameterDescription
uuid A UUID.

Return value

timestamptz (or the version as smallint).

Examples

Read the timestamp
SELECT uuid_extract_timestamp('019a0b6c-4e00-7000-8000-000000000000') AS created;

Output

          created
----------------------------
 2025-10-22 10:17:18.592+00
(1 row)

Run this on your computer — see “Get Started” for setup.

Version 4 has no time
SELECT uuid_extract_version(gen_random_uuid()) AS v4, uuid_extract_timestamp(gen_random_uuid()) AS no_time;

Output

 v4 | no_time
----+---------
  4 | NULL
(1 row)

Run this on your computer — see “Get Started” for setup.

Version history

VersionChange
PostgreSQL 17Added

Was this page helpful?