## Syntax ```mermaid %%{init: { 'theme': 'base', 'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' }, 'themeVariables': { 'fontSize': '11px', 'fontFamily': 'Arial' } }}%% flowchart LR Start((START)) --> UUID_EXTRACT_TIMESTAMP[UUID_EXTRACT_TIMESTAMP]:::quoted UUID_EXTRACT_TIMESTAMP --> End((END)) ``` ## Purpose The `UUID_EXTRACT_TIMESTAMP` SQL function returns the time of creation which is stored in a UUID of version 1, 6 or 7, in UTC. PostgreSQL reads version 1 and 7; version 6 holds the same time as version 1 and is read here as well. Use it to date an ID, such as the ID in the small print of an error message of Invantive products, which is a UUID of version 7 in the releases built from November 2026. Other UUIDs hold no time. The function returns `null` for a UUID of another version, for the empty UUID, for a UUID of another variant than RFC 9562, and for `null`. Older IDs of errors are random UUIDs of version 4 and therefore give `null`. The function is available under the same name in PostgreSQL 18. Available from release 28.0. See also [[UUIDV7]], [[UUID_GENERATE_V1]], [[UUID_GENERATE_V6]] and [[UUID_EXTRACT_VERSION]]. Parameters: - Input (`guid`): the UUID, or text of the form of a UUID. Text which is no UUID raises `itgenduy005`; check it first with [[IS_GUID]]. Returns: the time of creation in UTC, of data type `datetime`. ## Examples The following example reads the time of a UUID of version 7, with the format of the answer chosen: ```sql select to_char(uuid_extract_timestamp('019535d9-3df7-79fb-b466-fa907fa17f9e'), 'YYYY-MM-DD HH24:MI:SS') created -------------------- 2025-02-24 02:46:24 ``` The following example reads the time of a UUID of version 1: ```sql select to_char(uuid_extract_timestamp('c232ab00-9414-11ec-b3c8-9e6bdeced846'), 'YYYY-MM-DD HH24:MI:SS') created -------------------- 2022-02-22 19:22:22 ``` The following example returns `null`, since a random UUID holds no time: ```sql select uuid_extract_timestamp(uuidv4()) created -------- null ```