---
title: to_uuidv7() | Tiger Data Docs
description: Create a version 7 UUID from a Postgres timestamp
---

Since [2.23.0](https://github.com/timescale/timescaledb/releases/tag/2.23.0)

Create a UUIDv7 object from a PostgreSQL timestamp and random bits.

`ts` is converted to a UNIX timestamp split into millisecond and sub-millisecond parts.

![UUIDv7 structure with microsecond-precision timestamp](/docs/_astro/uuidv7-structure-microseconds.BBrmloq3.svg)

## Samples

```
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;
```

## Arguments

The syntax is:

```
SELECT to_uuidv7(
    timestamp = <timestamptz>
);
```

| Name | Type        | Default | Required | Description                                  |
| ---- | ----------- | ------- | -------- | -------------------------------------------- |
| `ts` | TIMESTAMPTZ | -       | ✔        | The timestamp used to return a UUIDv7 object |

## Returns

| Column      | Type | Description                                                        |
| ----------- | ---- | ------------------------------------------------------------------ |
| `to_uuidv7` | UUID | A UUIDv7 object created from the input timestamp with random bits. |
