Type conversion functions

**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**

- `x` — Number of seconds 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 and Time. [`DateTime`](/docs/sql-reference/data-types/datetime)

**Examples**

**Usage example**

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

```
┌─reinterpretAsDateTime(65)─┬─reinterpretAsDateTime('A')─┐
│       1970-01-01 01:01:05 │        1970-01-01 01:01:05 │
└───────────────────────────┴────────────────────────────┘
```

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

Introduced in: v1.1.0

Reinterprets the input value as a fixed string (assuming little endian order).
Null bytes at the end are ignored, for example, the function returns for UInt32 value 255 a string with a single character.

**Syntax**

```
reinterpretAsFixedString(x)
```

**Arguments**

- `x` — Value to reinterpret to string. [`(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)

**Returned value**

Fixed string containing bytes representing `x`. [`FixedString`](/docs/sql-reference/data-types/fixedstring)

**Examples**

**Usage example**

```
SELECT
    reinterpretAsFixedString(toDateTime('1970-01-01 01:01:05')),
    reinterpretAsFixedString(toDate('1970-03-07'))
```

```
┌─reinterpretAsFixedString(toDateTime('1970-01-01 01:01:05'))─┬─reinterpretAsFixedString(toDate('1970-03-07'))─┐
│ A                                                           │ A                                              │
└─────────────────────────────────────────────────────────────┴────────────────────────────────────────────────┘
```

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

Introduced in: v1.1.0

Reinterprets the input value as a value of type Float32.
Unlike [`CAST`](#CAST), the function does not attempt to preserve the original value - if the target type is not able to represent the input type, the output is undefined.

**Syntax**

```
reinterpretAsFloat32(x)
```

**Arguments**

- `x` — Value to reinterpret as Float32. [`(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**

Returns the reinterpreted value `x`. [`Float32`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT reinterpretAsUInt32(toFloat32(0.2)) AS x, reinterpretAsFloat32(x)
```

```
┌──────────x─┬─reinterpretAsFloat32(x)─┐
│ 1045220557 │                     0.2 │
└────────────┴─────────────────────────┘
```

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

Introduced in: v1.1.0

Reinterprets the input value as a value of type Float64.
Unlike [`CAST`](#CAST), the function does not attempt to preserve the original value - if the target type is not able to represent the input type, the output is undefined.

**Syntax**

```
reinterpretAsFloat64(x)
```

**Arguments**

- `x` — Value to reinterpret as Float64. [`(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**

Returns the reinterpreted value `x`. [`Float64`](/docs/sql-reference/data-types/float)

**Examples**

**Usage example**

```
SELECT reinterpretAsUInt64(toFloat64(0.2)) AS x, reinterpretAsFloat64(x)
```

```
┌───────────────────x─┬─reinterpretAsFloat64(x)─┐
│ 4596373779694328218 │                     0.2 │
└─────────────────────┴─────────────────────────┘
```

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

Introduced in: v1.1.0

Reinterprets the input value as a value of type Int128.
Unlike [`CAST`](#CAST), the function does not attempt to preserve the original value - if the target type is not able to represent the input type, the output is undefined.

**Syntax**

```
reinterpretAsInt128(x)
```

**Arguments**

- `x` — Value to reinterpret as Int128. [`(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**

Returns the reinterpreted value `x`. [`Int128`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT
    toInt64(257) AS x,
    toTypeName(x),
    reinterpretAsInt128(x) AS res,
    toTypeName(res)
```

```
┌───x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 257 │ Int64         │ 257 │ Int128          │
└─────┴───────────────┴─────┴─────────────────┘
```

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

Introduced in: v1.1.0

Reinterprets the input value as a value of type Int16.
Unlike [`CAST`](#CAST), the function does not attempt to preserve the original value - if the target type is not able to represent the input type, the output is undefined.

**Syntax**

```
reinterpretAsInt16(x)
```

**Arguments**

- `x` — Value to reinterpret as Int16. [`(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**

Returns the reinterpreted value `x`. [`Int16`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT
    toInt8(257) AS x,
    toTypeName(x),
    reinterpretAsInt16(x) AS res,
    toTypeName(res)
```

```
┌─x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 1 │ Int8          │   1 │ Int16           │
└───┴───────────────┴─────┴─────────────────┘
```

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

Introduced in: v1.1.0

Reinterprets the input value as a value of type Int256.
Unlike [`CAST`](#CAST), the function does not attempt to preserve the original value - if the target type is not able to represent the input type, the output is undefined.

**Syntax**

```
reinterpretAsInt256(x)
```

**Arguments**