Type conversion functions

**Examples**

**Usage example**

```
WITH
    toDate('2025-06-15') AS date,
    toIntervalHour(12) AS interval_to_hours
SELECT date + interval_to_hours AS result
```

```
┌──────────────result─┐
│ 2025-06-15 12:00:00 │
└─────────────────────┘
```

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

Introduced in: v22.6.0

Returns an interval of `n` microseconds of data type [`IntervalMicrosecond`](/docs/sql-reference/data-types/special-data-types/interval).

**Syntax**

```
toIntervalMicrosecond(n)
```

**Arguments**

- `n` — Number of microseconds. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns an interval of `n` microseconds. [`Interval`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
WITH
    toDateTime('2025-06-15') AS date,
    toIntervalMicrosecond(30) AS interval_to_microseconds
SELECT date + interval_to_microseconds AS result
```

```
┌─────────────────────result─┐
│ 2025-06-15 00:00:00.000030 │
└────────────────────────────┘
```

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

Introduced in: v22.6.0

Returns an interval of `n` milliseconds of data type [IntervalMillisecond](/docs/sql-reference/data-types/special-data-types/interval).

**Syntax**

```
toIntervalMillisecond(n)
```

**Arguments**

- `n` — Number of milliseconds. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns an interval of `n` milliseconds. [`Interval`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
WITH
    toDateTime('2025-06-15') AS date,
    toIntervalMillisecond(30) AS interval_to_milliseconds
SELECT date + interval_to_milliseconds AS result
```

```
┌──────────────────result─┐
│ 2025-06-15 00:00:00.030 │
└─────────────────────────┘
```

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

Introduced in: v1.1.0

Returns an interval of `n` minutes of data type [`IntervalMinute`](/docs/sql-reference/data-types/special-data-types/interval).

**Syntax**

```
toIntervalMinute(n)
```

**Arguments**

- `n` — Number of minutes. Integer numbers or string representations thereof, and float numbers. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns an interval of `n` minutes. [`Interval`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
WITH
    toDate('2025-06-15') AS date,
    toIntervalMinute(12) AS interval_to_minutes
SELECT date + interval_to_minutes AS result
```

```
┌──────────────result─┐
│ 2025-06-15 00:12:00 │
└─────────────────────┘
```

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

Introduced in: v1.1.0

Returns an interval of `n` months of data type [`IntervalMonth`](/docs/sql-reference/data-types/special-data-types/interval).

**Syntax**

```
toIntervalMonth(n)
```

**Arguments**

- `n` — Number of months. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns an interval of `n` months. [`Interval`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
WITH
    toDate('2025-06-15') AS date,
    toIntervalMonth(1) AS interval_to_month
SELECT date + interval_to_month AS result
```

```
┌─────result─┐
│ 2025-07-15 │
└────────────┘
```

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

Introduced in: v22.6.0

Returns an interval of `n` nanoseconds of data type [`IntervalNanosecond`](/docs/sql-reference/data-types/special-data-types/interval).

**Syntax**

```
toIntervalNanosecond(n)
```

**Arguments**

- `n` — Number of nanoseconds. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns an interval of `n` nanoseconds. [`Interval`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
WITH
    toDateTime('2025-06-15') AS date,
    toIntervalNanosecond(30) AS interval_to_nanoseconds
SELECT date + interval_to_nanoseconds AS result
```

```
┌────────────────────────result─┐
│ 2025-06-15 00:00:00.000000030 │
└───────────────────────────────┘
```

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

Introduced in: v1.1.0

Returns an interval of `n` quarters of data type [`IntervalQuarter`](/docs/sql-reference/data-types/special-data-types/interval).

**Syntax**

```
toIntervalQuarter(n)
```

**Arguments**

- `n` — Number of quarters. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns an interval of `n` quarters. [`Interval`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
WITH
    toDate('2025-06-15') AS date,
    toIntervalQuarter(1) AS interval_to_quarter
SELECT date + interval_to_quarter AS result
```

```
┌─────result─┐
│ 2025-09-15 │
└────────────┘
```

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

Introduced in: v1.1.0

Returns an interval of `n` seconds of data type [`IntervalSecond`](/docs/sql-reference/data-types/special-data-types/interval).

**Syntax**

```
toIntervalSecond(n)
```

**Arguments**

- `n` — Number of seconds. Integer numbers or string representations thereof, and float numbers. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns an interval of `n` seconds. [`Interval`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
WITH
    toDate('2025-06-15') AS date,
    toIntervalSecond(30) AS interval_to_seconds
SELECT date + interval_to_seconds AS result
```

```
┌──────────────result─┐
│ 2025-06-15 00:00:30 │
└─────────────────────┘
```

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

Introduced in: v1.1.0

Returns an interval of `n` weeks of data type [`IntervalWeek`](/docs/sql-reference/data-types/special-data-types/interval).

**Syntax**

```
toIntervalWeek(n)
```

**Arguments**

- `n` — Number of weeks. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns an interval of `n` weeks. [`Interval`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
WITH
    toDate('2025-06-15') AS date,
    toIntervalWeek(1) AS interval_to_week
SELECT date + interval_to_week AS result
```

```
┌─────result─┐
│ 2025-06-22 │
└────────────┘
```

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

Introduced in: v1.1.0

Returns an interval of `n` years of data type [`IntervalYear`](/docs/sql-reference/data-types/special-data-types/interval).

**Syntax**

```
toIntervalYear(n)
```

**Arguments**

- `n` — Number of years. [`(U)Int*`](/docs/sql-reference/data-types/int-uint) or [`Float*`](/docs/sql-reference/data-types/float) or [`String`](/docs/sql-reference/data-types/string)

**Returned value**

Returns an interval of `n` years. [`Interval`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
WITH
    toDate('2024-06-15') AS date,
    toIntervalYear(1) AS interval_to_year
SELECT date + interval_to_year AS result
```

```
┌─────result─┐
│ 2025-06-15 │
└────────────┘
```

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

Introduced in: v18.12.0