> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Documentation for functions used for working with ULIDs

# Functions for working with ULIDs

<Note>
  The documentation below is generated from the `system.functions` system table.
</Note>

{/*AUTOGENERATED_START*/}

<h2 id="ULIDStringToDateTime">
  ULIDStringToDateTime
</h2>

Introduced in: v23.3.0

This function extracts the timestamp from a [ULID](https://github.com/ulid/spec).

**Syntax**

```sql theme={null}
ULIDStringToDateTime(ulid[, timezone])
```

**Arguments**

* `ulid` — Input ULID. [`String`](/reference/data-types/string) or [`FixedString(26)`](/reference/data-types/fixedstring)
* `timezone` — Optional. Timezone name for the returned value. [`String`](/reference/data-types/string)

**Returned value**

Timestamp with milliseconds precision. [`DateTime64(3)`](/reference/data-types/datetime64)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ULIDStringToDateTime('01GNB2S2FGN2P93QPXDNB4EN2R')
```

```response title=Response theme={null}
┌─ULIDStringToDateTime('01GNB2S2FGN2P93QPXDNB4EN2R')─┐
│                            2022-12-28 00:40:37.616 │
└────────────────────────────────────────────────────┘
```

<h2 id="generateULID">
  generateULID
</h2>

Introduced in: v23.2.0

Generates a [Universally Unique Lexicographically Sortable Identifier (ULID)](https://github.com/ulid/spec).

**Syntax**

```sql theme={null}
generateULID([x])
```

**Arguments**

* `x` — Optional. An expression resulting in any of the supported data types. The resulting value is discarded, but the expression itself if used for bypassing [common subexpression elimination](/reference/functions/regular-functions/overview#common-subexpression-elimination) if the function is called multiple times in one query. [`Any`](/reference/data-types/index)

**Returned value**

Returns a ULID. [`FixedString(26)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT generateULID()
```

```response title=Response theme={null}
┌─generateULID()─────────────┐
│ 01GNB2S2FGN2P93QPXDNB4EN2R │
└────────────────────────────┘
```

**Usage example if it is needed to generate multiple values in one row**

```sql title=Query theme={null}
SELECT generateULID(1), generateULID(2)
```

```response title=Response theme={null}
┌─generateULID(1)────────────┬─generateULID(2)────────────┐
│ 01GNB2SGG4RHKVNT9ZGA4FFMNP │ 01GNB2SGG4V0HMQVH4VBVPSSRB │
└────────────────────────────┴────────────────────────────┘
```

<h2 id="see-also">
  See also
</h2>

* [UUID](/reference/functions/regular-functions/uuid-functions)
