Type conversion functions

**Syntax**

```
parseDateTimeInJodaSyntax(time_string, format[, timezone])
```

**Arguments**

- `time_string` — String to be parsed into DateTime. [`String`](/docs/sql-reference/data-types/string)
- `format` — Format string in Joda syntax specifying how to parse time\_string. [`String`](/docs/sql-reference/data-types/string)
- `timezone` — Optional. Timezone. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns a DateTime parsed from the input string according to the Joda style format string. [`DateTime`](/docs/sql-reference/data-types/datetime)

**Examples**

**Usage example**

```
SELECT parseDateTimeInJodaSyntax('2025-01-04 23:00:00', 'yyyy-MM-dd HH:mm:ss')
```

```
┌─parseDateTimeInJodaSyntax('2025-01-04 23:00:00', 'yyyy-MM-dd HH:mm:ss')─┐
│                                                      2025-01-04 23:00:00 │
└──────────────────────────────────────────────────────────────────────────┘
```

## parseDateTimeInJodaSyntaxOrNull[​](#parseDateTimeInJodaSyntaxOrNull "Direct link to parseDateTimeInJodaSyntaxOrNull")

Introduced in: v23.3.0

Same as [`parseDateTimeInJodaSyntax`](#parseDateTimeInJodaSyntax) but returns `NULL` when it encounters an unparsable date format.

**Syntax**

```
parseDateTimeInJodaSyntaxOrNull(time_string, format[, timezone])
```

**Arguments**

- `time_string` — String to be parsed into DateTime. [`String`](/docs/sql-reference/data-types/string)
- `format` — Format string in Joda syntax specifying how to parse time\_string. [`String`](/docs/sql-reference/data-types/string)
- `timezone` — Optional. Timezone. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns DateTime parsed from input string, or NULL if parsing fails. [`Nullable(DateTime)`](/docs/sql-reference/data-types/nullable)

**Examples**

**Usage example**

```
SELECT parseDateTimeInJodaSyntaxOrNull('2025-01-04 23:00:00', 'yyyy-MM-dd HH:mm:ss')
```

```
┌─parseDateTimeInJodaSyntaxOrNull('2025-01-04 23:00:00', 'yyyy-MM-dd HH:mm:ss')─┐
│                                                         2025-01-04 23:00:00    │
└────────────────────────────────────────────────────────────────────────────────┘
```

## parseDateTimeInJodaSyntaxOrZero[​](#parseDateTimeInJodaSyntaxOrZero "Direct link to parseDateTimeInJodaSyntaxOrZero")

Introduced in: v23.3.0

Same as [`parseDateTimeInJodaSyntax`](#parseDateTimeInJodaSyntax) but returns zero date when it encounters an unparsable date format.

**Syntax**

```
parseDateTimeInJodaSyntaxOrZero(time_string, format[, timezone])
```

**Arguments**

- `time_string` — String to be parsed into DateTime. [`String`](/docs/sql-reference/data-types/string)
- `format` — Format string in Joda syntax specifying how to parse time\_string. [`String`](/docs/sql-reference/data-types/string)
- `timezone` — Optional. Timezone. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns DateTime parsed from input string, or zero DateTime if parsing fails. [`DateTime`](/docs/sql-reference/data-types/datetime)

**Examples**

**Usage example**

```
SELECT parseDateTimeInJodaSyntaxOrZero('2025-01-04 23:00:00', 'yyyy-MM-dd HH:mm:ss')
```

```
┌─parseDateTimeInJodaSyntaxOrZero('2025-01-04 23:00:00', 'yyyy-MM-dd HH:mm:ss')─┐
│                                                          2025-01-04 23:00:00   │
└────────────────────────────────────────────────────────────────────────────────┘
```

## parseDateTimeOrNull[​](#parseDateTimeOrNull "Direct link to parseDateTimeOrNull")

Introduced in: v23.3.0

Same as [`parseDateTime`](#parseDateTime) but returns `NULL` when it encounters an unparsable date format.

**Syntax**

```
parseDateTimeOrNull(time_string, format[, timezone])
```

**Aliases**: `str_to_date`

**Arguments**

- `time_string` — String to be parsed into DateTime. [`String`](/docs/sql-reference/data-types/string)
- `format` — Format string specifying how to parse time\_string. [`String`](/docs/sql-reference/data-types/string)
- `timezone` — Optional. Timezone. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns DateTime parsed from input string, or NULL if parsing fails. [`Nullable(DateTime)`](/docs/sql-reference/data-types/nullable)

**Examples**

**Usage example**

```
SELECT parseDateTimeOrNull('2025-01-04+23:00:00', '%Y-%m-%d+%H:%i:%s')
```

```
┌─parseDateTimeOrNull('2025-01-04+23:00:00', '%Y-%m-%d+%H:%i:%s')─┐
│                                            2025-01-04 23:00:00  │
└─────────────────────────────────────────────────────────────────┘
```

## parseDateTimeOrZero[​](#parseDateTimeOrZero "Direct link to parseDateTimeOrZero")

Introduced in: v23.3.0

Same as [`parseDateTime`](#parseDateTime) but returns zero date when it encounters an unparsable date format.

**Syntax**

```
parseDateTimeOrZero(time_string, format[, timezone])
```

**Arguments**

- `time_string` — String to be parsed into DateTime. [`String`](/docs/sql-reference/data-types/string)
- `format` — Format string specifying how to parse time\_string. [`String`](/docs/sql-reference/data-types/string)
- `timezone` — Optional. Timezone. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns DateTime parsed from input string, or zero DateTime if parsing fails. [`DateTime`](/docs/sql-reference/data-types/datetime)

**Examples**

**Usage example**

```
SELECT parseDateTimeOrZero('2025-01-04+23:00:00', '%Y-%m-%d+%H:%i:%s')
```

```
┌─parseDateTimeOrZero('2025-01-04+23:00:00', '%Y-%m-%d+%H:%i:%s')─┐
│                                             2025-01-04 23:00:00 │
└─────────────────────────────────────────────────────────────────┘
```

## reinterpret[​](#reinterpret "Direct link to reinterpret")

Introduced in: v1.1.0

Uses the same source in-memory bytes sequence for the provided value `x` and reinterprets it to the destination type.

**Syntax**

```
reinterpret(x, type)
```

**Arguments**

- `x` — Any type. [`Any`](/docs/sql-reference/data-types)
- `type` — Destination type. If it is an array, then the array element type must be a fixed length type. [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Destination type value. [`Any`](/docs/sql-reference/data-types)

**Examples**

**Usage example**

```
SELECT reinterpret(toInt8(-1), 'UInt8') AS int_to_uint,
    reinterpret(toInt8(1), 'Float32') AS int_to_float,
    reinterpret('1', 'UInt32') AS string_to_int
```

```
┌─int_to_uint─┬─int_to_float─┬─string_to_int─┐
│         255 │        1e-45 │            49 │
└─────────────┴──────────────┴───────────────┘
```

**Array example**

```
SELECT reinterpret(x'3108b4403108d4403108b4403108d440', 'Array(Float32)') AS string_to_array_of_Float32
```

```
┌─string_to_array_of_Float32─┐
│ [5.626,6.626,5.626,6.626]  │
└────────────────────────────┘
```

## reinterpretAsDate[​](#reinterpretAsDate "Direct link to reinterpretAsDate")

Introduced in: v1.1.0

Reinterprets the input value as a Date value (assuming little endian order) which is the number of days since the beginning of the Unix epoch 1970-01-01

**Syntax**

```
reinterpretAsDate(x)
```

**Arguments**

- `x` — Number of days since the beginning of the Unix Epoch. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`Date`](/docs/sql-reference/data-types/date) or [`DateTime`](/docs/sql-reference/data-types/datetime) or [`UUID`](/docs/sql-reference/data-types/uuid) or [`String`](/docs/sql-reference/data-types/string) or [`FixedString`](/docs/sql-reference/data-types/fixedstring)

**Returned value**

Date. [`Date`](/docs/sql-reference/data-types/date)

**Examples**

**Usage example**

```
SELECT reinterpretAsDate(65), reinterpretAsDate('A')
```

```
┌─reinterpretAsDate(65)─┬─reinterpretAsDate('A')─┐
│            1970-03-07 │             1970-03-07 │
└───────────────────────┴────────────────────────┘
```

## reinterpretAsDateTime[​](#reinterpretAsDateTime "Direct link to reinterpretAsDateTime")

Introduced in: v1.1.0

Reinterprets the input value as a DateTime value (assuming little endian order) which is the number of days since the beginning of the Unix epoch 1970-01-01

**Syntax**

```
reinterpretAsDateTime(x)
```

**Arguments**