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

> 형 변환 함수 문서

# 형 변환 함수

<div id="common-issues-with-data-conversion">
  ## 데이터 변환 시 일반적으로 발생하는 문제
</div>

ClickHouse는 일반적으로 [C++ 프로그램과 동일한 동작 방식](https://en.cppreference.com/w/cpp/language/implicit_conversion)을 사용합니다.

`to<type>` 함수와 [cast](#CAST)는 일부 경우에 서로 다르게 동작합니다. 예를 들어 [LowCardinality](/ko/reference/data-types/lowcardinality)의 경우 [cast](#CAST)는 [LowCardinality](/ko/reference/data-types/lowcardinality) 특성을 제거하지만, `to<type>` 함수는 제거하지 않습니다. [Nullable](/ko/reference/data-types/nullable)도 마찬가지입니다. 이러한 동작은 SQL 표준과 호환되지 않으며, [cast\_keep\_nullable](/ko/reference/settings/session-settings#cast_keep_nullable) 설정으로 변경할 수 있습니다.

<Note>
  데이터 타입의 값을 더 작은 데이터 타입으로 변환할 때(예: `Int64`에서 `Int32`로) 또는
  호환되지 않는 데이터 타입 간에 변환할 때(예: `String`에서 `Int`로) 데이터가 손실될 수 있으므로 주의하십시오. 결과가 예상한 대로인지 반드시 신중하게 확인하십시오.
</Note>

예시:

```sql theme={null}
SELECT
    toTypeName(toLowCardinality('') AS val) AS source_type,
    toTypeName(toString(val)) AS to_type_result_type,
    toTypeName(CAST(val, 'String')) AS cast_result_type

┌─source_type────────────┬─to_type_result_type────┬─cast_result_type─┐
│ LowCardinality(String) │ LowCardinality(String) │ String           │
└────────────────────────┴────────────────────────┴──────────────────┘

SELECT
    toTypeName(toNullable('') AS val) AS source_type,
    toTypeName(toString(val)) AS to_type_result_type,
    toTypeName(CAST(val, 'String')) AS cast_result_type

┌─source_type──────┬─to_type_result_type─┬─cast_result_type─┐
│ Nullable(String) │ Nullable(String)    │ String           │
└──────────────────┴─────────────────────┴──────────────────┘

SELECT
    toTypeName(toNullable('') AS val) AS source_type,
    toTypeName(toString(val)) AS to_type_result_type,
    toTypeName(CAST(val, 'String')) AS cast_result_type
SETTINGS cast_keep_nullable = 1

┌─source_type──────┬─to_type_result_type─┬─cast_result_type─┐
│ Nullable(String) │ Nullable(String)    │ Nullable(String) │
└──────────────────┴─────────────────────┴──────────────────┘
```

<div id="to-string-functions">
  ## `toString` 함수에 대한 참고 사항
</div>

`toString` 계열 함수는 숫자, 문자열(고정 문자열 제외), 날짜, 날짜와 시간을 서로 변환할 수 있도록 합니다.
이 함수들은 모두 하나의 인수를 받습니다.

* 문자열로 변환하거나 문자열에서 변환할 때는 TabSeparated 포맷(및 거의 모든 다른 텍스트 형식)과 동일한 규칙에 따라 값을 포맷하거나 파싱합니다. 문자열을 파싱할 수 없으면 예외가 발생하고 요청이 취소됩니다.
* 날짜를 숫자로 변환하거나 그 반대로 변환할 때 날짜는 Unix epoch 시작 이후 경과한 일 수에 해당합니다.
* 날짜와 시간을 숫자로 변환하거나 그 반대로 변환할 때 날짜와 시간은 Unix epoch 시작 이후 경과한 초 수에 해당합니다.
* `DateTime` 인수에 대한 `toString` 함수는 시간대 이름을 포함하는 두 번째 String 인수를 받을 수 있습니다. 예를 들어 `Europe/Amsterdam`입니다. 이 경우 시간은 지정된 시간대에 따라 포맷됩니다.

<div id="to-date-and-date-time-functions">
  ## `toDate`/`toDateTime` 함수 관련 참고 사항
</div>

`toDate`/`toDateTime` 함수의 날짜 형식과 날짜-시간 형식은 다음과 같이 정의됩니다.

```response theme={null}
YYYY-MM-DD
YYYY-MM-DD hh:mm:ss
```

예외적으로, UInt32, Int32, UInt64 또는 Int64 숫자 타입을 Date로 변환할 때 값이 65536 이상이면, 그 값은 일 수가 아니라 Unix timestamp로 해석되며 Date로 반올림됩니다.
이 동작을 통해 흔히 사용되는 `toDate(unix_timestamp)`를 지원할 수 있습니다. 그렇지 않으면 오류가 발생하며, 더 번거로운 `toDate(toDateTime(unix_timestamp))`를 작성해야 합니다.

날짜와 날짜와 시간 간 변환은 자연스러운 방식으로 수행됩니다. 즉, 시간이 없는 00:00:00을 추가하거나 시간 부분을 제거합니다.

숫자 타입 간 변환에는 C++에서 서로 다른 숫자 타입 사이에 값을 할당할 때와 동일한 규칙이 적용됩니다.

**예시**

```sql title="Query" theme={null}
SELECT
    now() AS ts,
    time_zone,
    toString(ts, time_zone) AS str_tz_datetime
FROM system.time_zones
WHERE time_zone LIKE 'Europe%'
LIMIT 10
```

```response title="Response" theme={null}
┌──────────────────ts─┬─time_zone─────────┬─str_tz_datetime─────┐
│ 2023-09-08 19:14:59 │ Europe/Amsterdam  │ 2023-09-08 21:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Andorra    │ 2023-09-08 21:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Astrakhan  │ 2023-09-08 23:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Athens     │ 2023-09-08 22:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Belfast    │ 2023-09-08 20:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Belgrade   │ 2023-09-08 21:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Berlin     │ 2023-09-08 21:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Bratislava │ 2023-09-08 21:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Brussels   │ 2023-09-08 21:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Bucharest  │ 2023-09-08 22:14:59 │
└─────────────────────┴───────────────────┴─────────────────────┘
```

[`toUnixTimestamp`](/ko/reference/functions/regular-functions/date-time-functions#toUnixTimestamp) 함수도 함께 참고하십시오.

{/*AUTOGENERATED_START*/}

<div id="CAST">
  ## CAST
</div>

도입 버전: v1.1.0

값을 지정된 데이터 타입으로 변환합니다.
reinterpret 함수와 달리, CAST는 대상 데이터 타입에서 동일한 값을 생성하려고 시도합니다.
이것이 불가능하면 예외가 발생합니다.

**구문**

```sql theme={null}
CAST(x, T)
or CAST(x AS T)
or x::T
```

**인수**

* `x` — 임의의 타입의 값입니다. [`Any`](/ko/reference/data-types/index)
* `T` — 대상 데이터 타입입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

대상 데이터 타입으로 변환된 값을 반환합니다. [`Any`](/ko/reference/data-types/index)

**예시**

**기본 사용법**

```sql title=Query theme={null}
SELECT CAST(42, 'String')
```

```response title=Response theme={null}
┌─CAST(42, 'String')─┐
│ 42                 │
└────────────────────┘
```

**AS 구문 사용하기**

```sql title=Query theme={null}
SELECT CAST('2025-01-01' AS Date)
```

```response title=Response theme={null}
┌─CAST('2025-01-01', 'Date')─┐
│                 2025-01-01 │
└────────────────────────────┘
```

**:: 구문 사용**

```sql title=Query theme={null}
SELECT '123'::UInt32
```

```response title=Response theme={null}
┌─CAST('123', 'UInt32')─┐
│                   123 │
└───────────────────────┘
```

<div id="DATE">
  ## DATE
</div>

도입 버전: v21.2.0

인수를 Date 데이터 타입으로 변환합니다. `toDate`의 MySQL 호환 별칭이며, 동작은 `toDate`와 동일합니다.

**구문**

```sql theme={null}
DATE(expr)
```

**인수**

* `expr` — 변환할 값입니다. [`String`](/ko/reference/data-types/string), [`UInt32`](/ko/reference/data-types/int-uint), [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime)

**반환 값**

`Date` 값을 반환합니다. [`Date`](/ko/reference/data-types/date)

**예시**

**기본 사용법**

```sql title=Query theme={null}
SELECT DATE('2023-01-01')
```

```response title=Response theme={null}
2023-01-01
```

<div id="accurateCast">
  ## accurateCast
</div>

도입 버전: v1.1.0

값을 지정된 데이터 타입으로 변환합니다. [`CAST`](#CAST)와 달리 `accurateCast`는 더 엄격한 타입 검사를 수행하며, 변환 시 데이터 정밀도가 손실되거나 변환이 불가능하면 예외를 발생시킵니다.

이 함수는 정밀도 손실과 잘못된 변환을 방지하므로 일반 `CAST`보다 안전합니다.

**구문**

```sql theme={null}
accurateCast(x, T)
```

**인수**

* `x` — 변환할 값입니다. [`Any`](/ko/reference/data-types/index)
* `T` — 대상 데이터 타입의 이름입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

대상 데이터 타입으로 변환된 값을 반환합니다. [`Any`](/ko/reference/data-types/index)

**예시**

**변환에 성공한 경우**

```sql title=Query theme={null}
SELECT accurateCast(42, 'UInt16')
```

```response title=Response theme={null}
┌─accurateCast(42, 'UInt16')─┐
│                        42 │
└───────────────────────────┘
```

**String에서 숫자로 변환**

```sql title=Query theme={null}
SELECT accurateCast('123.45', 'Float64')
```

```response title=Response theme={null}
┌─accurateCast('123.45', 'Float64')─┐
│                            123.45 │
└───────────────────────────────────┘
```

<div id="accurateCastOrDefault">
  ## accurateCastOrDefault
</div>

도입 버전: v21.1.0

값을 지정된 데이터 타입으로 변환합니다.
[`accurateCast`](#accurateCast)와 유사하지만, 변환을 정확하게 수행할 수 없는 경우 예외를 발생시키는 대신 기본값을 반환합니다.

기본값이 두 번째 인수로 제공되면 해당 값은 대상 데이터 타입이어야 합니다.
기본값이 제공되지 않으면 대상 데이터 타입의 기본값이 사용됩니다.

**구문**

```sql theme={null}
accurateCastOrDefault(x, T[, default_value])
```

**인수**

* `x` — 변환할 값입니다. [`Any`](/ko/reference/data-types/index)
* `T` — 대상 데이터 타입의 이름입니다. [`const String`](/ko/reference/data-types/string)
* `default_value` — 선택 사항입니다. 변환에 실패하면 반환할 기본값입니다. [`Any`](/ko/reference/data-types/index)

**반환 값**

대상 데이터 타입으로 변환된 값 또는 변환할 수 없는 경우 기본값을 반환합니다. [`Any`](/ko/reference/data-types/index)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT accurateCastOrDefault(42, 'String')
```

```response title=Response theme={null}
┌─accurateCastOrDefault(42, 'String')─┐
│ 42                                  │
└─────────────────────────────────────┘
```

**명시적으로 지정한 기본값을 사용한 변환 실패**

```sql title=Query theme={null}
SELECT accurateCastOrDefault('abc', 'UInt32', 999::UInt32)
```

```response title=Response theme={null}
┌─accurateCastOrDefault('abc', 'UInt32', 999)─┐
│                                         999 │
└─────────────────────────────────────────────┘
```

**암시적 기본값으로 인한 변환 실패**

```sql title=Query theme={null}
SELECT accurateCastOrDefault('abc', 'UInt32')
```

```response title=Response theme={null}
┌─accurateCastOrDefault('abc', 'UInt32')─┐
│                                      0 │
└────────────────────────────────────────┘
```

<div id="accurateCastOrNull">
  ## accurateCastOrNull
</div>

도입 버전: v1.1.0

값을 지정된 데이터 타입으로 변환합니다.
[`accurateCast`](#accurateCast)와 유사하지만, 변환을 정확하게 수행할 수 없으면 예외를 발생시키는 대신 `NULL`을 반환합니다.

이 함수는 [`accurateCast`](#accurateCast)의 안전성과 안정적인 오류 처리를 결합합니다.

**구문**

```sql theme={null}
accurateCastOrNull(x, T)
```

**인수**

* `x` — 변환할 값입니다. [`Any`](/ko/reference/data-types/index)
* `T` — 대상 데이터 타입의 이름입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

대상 데이터 타입으로 변환된 값을 반환합니다. 변환이 불가능하면 `NULL`을 반환합니다. [`Any`](/ko/reference/data-types/index)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT accurateCastOrNull(42, 'String')
```

```response title=Response theme={null}
┌─accurateCastOrNull(42, 'String')─┐
│ 42                               │
└──────────────────────────────────┘
```

**변환에 실패하면 NULL을 반환합니다**

```sql title=Query theme={null}
SELECT accurateCastOrNull('abc', 'UInt32')
```

```response title=Response theme={null}
┌─accurateCastOrNull('abc', 'UInt32')─┐
│                                ᴺᵁᴸᴸ │
└─────────────────────────────────────┘
```

<div id="formatRow">
  ## formatRow
</div>

도입 버전: v20.7.0

지정한 포맷을 사용해 임의의 표현식을 문자열로 변환합니다.

<Note>
  포맷에 suffix/prefix가 포함되어 있으면 각 행마다 기록됩니다.
  이 함수는 행 기반 포맷만 지원합니다.
</Note>

**구문**

```sql theme={null}
formatRow(format, x, y, ...)
```

**인수**

* `format` — 텍스트 포맷입니다. 예를 들어 CSV, TSV가 있습니다. [`String`](/ko/reference/data-types/string)
* `x, y, ...` — 표현식입니다. [`Any`](/ko/reference/data-types/index)

**반환 값**

포맷된 문자열입니다. (텍스트 형식의 경우 일반적으로 줄바꿈 문자로 끝납니다). [`String`](/ko/reference/data-types/string)

**예시**

**기본 사용법**

```sql title=Query theme={null}
SELECT formatRow('CSV', number, 'good')
FROM numbers(3)
```

```response title=Response theme={null}
┌─formatRow('CSV', number, 'good')─┐
│ 0,"good"
                         │
│ 1,"good"
                         │
│ 2,"good"
                         │
└──────────────────────────────────┘
```

**사용자 지정 포맷 사용**

```sql title=Query theme={null}
SELECT formatRow('CustomSeparated', number, 'good')
FROM numbers(3)
SETTINGS format_custom_result_before_delimiter='<prefix>\n', format_custom_result_after_delimiter='<suffix>'
```

```response title=Response theme={null}
┌─formatRow('CustomSeparated', number, 'good')─┐
│ <prefix>
0    good
<suffix>                   │
│ <prefix>
1    good
<suffix>                   │
│ <prefix>
2    good
<suffix>                   │
└──────────────────────────────────────────────┘
```

<div id="formatRowNoNewline">
  ## formatRowNoNewline
</div>

도입 버전: v20.7.0

[`formatRow`](#formatRow)와 동일하지만, 각 행 끝의 줄바꿈 문자를 제거합니다.

지정된 포맷을 사용해 임의의 표현식을 문자열로 변환하되, 결과 끝에 붙는 줄바꿈 문자는 모두 제거합니다.

**구문**

```sql theme={null}
formatRowNoNewline(format, x, y, ...)
```

**인수**

* `format` — 텍스트 포맷입니다. 예를 들면 CSV, TSV가 있습니다. [`String`](/ko/reference/data-types/string)
* `x, y, ...` — 표현식입니다. [`Any`](/ko/reference/data-types/index)

**반환 값**

줄바꿈이 제거된 형식화된 문자열을 반환합니다. [`String`](/ko/reference/data-types/string)

**예시**

**기본 사용법**

```sql title=Query theme={null}
SELECT formatRowNoNewline('CSV', number, 'good')
FROM numbers(3)
```

```response title=Response theme={null}
┌─formatRowNoNewline('CSV', number, 'good')─┐
│ 0,"good"                                  │
│ 1,"good"                                  │
│ 2,"good"                                  │
└───────────────────────────────────────────┘
```

<div id="fromUnixTimestamp64Micro">
  ## fromUnixTimestamp64Micro
</div>

도입 버전: v20.5.0

마이크로초 단위의 Unix timestamp를 마이크로초 정밀도를 갖는 `DateTime64` 값으로 변환합니다.

입력 값은 마이크로초 정밀도의 Unix timestamp(1970-01-01 00:00:00 UTC 이후 경과한 마이크로초 수)로 처리됩니다.

**구문**

```sql theme={null}
fromUnixTimestamp64Micro(value[, timezone])
```

**인수**

* `value` — 마이크로초 단위의 Unix timestamp입니다. [`Int64`](/ko/reference/data-types/int-uint)
* `timezone` — 선택 사항입니다. 반환되는 값의 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

마이크로초 정밀도의 `DateTime64` 값을 반환합니다. [`DateTime64(6)`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

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

```response title=Response theme={null}
┌─fromUnixTimestamp64Micro(1640995200123456)─┐
│                 2022-01-01 00:00:00.123456 │
└────────────────────────────────────────────┘
```

<div id="fromUnixTimestamp64Milli">
  ## fromUnixTimestamp64Milli
</div>

도입 버전: v20.5.0

밀리초 단위 Unix timestamp를 밀리초 정밀도의 `DateTime64` 값으로 변환합니다.

입력 값은 밀리초 정밀도의 Unix timestamp(1970-01-01 00:00:00 UTC 이후 경과한 밀리초 수)로 처리됩니다.

**구문**

```sql theme={null}
fromUnixTimestamp64Milli(value[, timezone])
```

**인수**

* `value` — 밀리초 단위의 Unix timestamp입니다. [`Int64`](/ko/reference/data-types/int-uint)
* `timezone` — 선택 사항입니다. 반환 값의 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

밀리초 정밀도의 `DateTime64` 값입니다. [`DateTime64(3)`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

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

```response title=Response theme={null}
┌─fromUnixTimestamp64Milli(1640995200123)─┐
│                 2022-01-01 00:00:00.123 │
└─────────────────────────────────────────┘
```

<div id="fromUnixTimestamp64Nano">
  ## fromUnixTimestamp64Nano
</div>

도입 버전: v20.5.0

나노초 단위의 Unix timestamp를 나노초 정밀도를 가진 [`DateTime64`](/ko/reference/data-types/datetime64) 값으로 변환합니다.

입력 값은 나노초 정밀도의 Unix timestamp(1970-01-01 00:00:00 UTC 이후 경과한 나노초 수)로 간주됩니다.

<Note>
  입력 값은 입력 값에 지정된 시간대가 아니라 UTC timestamp로 간주된다는 점에 유의하십시오.
</Note>

**구문**

```sql theme={null}
fromUnixTimestamp64Nano(value[, timezone])
```

**인수**

* `value` — 나노초 단위의 Unix timestamp입니다. [`Int64`](/ko/reference/data-types/int-uint)
* `timezone` — 선택 사항입니다. 반환 값의 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

나노초 정밀도의 `DateTime64` 값을 반환합니다. [`DateTime64(9)`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

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

```response title=Response theme={null}
┌─fromUnixTimestamp64Nano(1640995200123456789)─┐
│                2022-01-01 00:00:00.123456789 │
└──────────────────────────────────────────────┘
```

<div id="fromUnixTimestamp64Second">
  ## fromUnixTimestamp64Second
</div>

도입 버전: v24.12.0

초 단위 Unix timestamp를 초 단위 정밀도의 `DateTime64` 값으로 변환합니다.

입력 값은 초 단위 정밀도의 Unix timestamp(1970-01-01 00:00:00 UTC 이후 경과한 초 수)로 처리됩니다.

**구문**

```sql theme={null}
fromUnixTimestamp64Second(value[, timezone])
```

**인수**

* `value` — 초 단위의 Unix timestamp입니다. [`Int64`](/ko/reference/data-types/int-uint)
* `timezone` — 선택 사항입니다. 반환 값에 사용할 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

초 단위 정밀도를 갖는 `DateTime64` 값을 반환합니다. [`DateTime64(0)`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

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

```response title=Response theme={null}
┌─fromUnixTimestamp64Second(1640995200)─┐
│                   2022-01-01 00:00:00 │
└───────────────────────────────────────┘
```

<div id="parseDateTime">
  ## parseDateTime
</div>

도입 버전: v23.3.0

MySQL 날짜 포맷 문자열에 따라 날짜 및 시간 문자열을 파싱합니다.

이 함수는 [`formatDateTime`](/ko/reference/functions/regular-functions/date-time-functions)의 역함수입니다.
포맷 String을 사용하여 String 인수를 파싱합니다. DateTime 유형을 반환합니다.

**구문**

```sql theme={null}
parseDateTime(time_string, format[, timezone])
```

**별칭**: `TO_UNIXTIME`

**인수**

* `time_string` — DateTime으로 파싱할 문자열입니다. [`String`](/ko/reference/data-types/string)
* `format` — `time_string`을 파싱하는 방법을 지정하는 포맷 문자열입니다. [`String`](/ko/reference/data-types/string)
* `timezone` — 선택 사항입니다. 시간대를 지정합니다. [`String`](/ko/reference/data-types/string)

**반환 값**

MySQL 스타일 포맷 문자열에 따라 입력 문자열을 파싱한 DateTime을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime('2025-01-04+23:00:00', '%Y-%m-%d+%H:%i:%s')
```

```response title=Response theme={null}
┌─parseDateTime('2025-01-04+23:00:00', '%Y-%m-%d+%H:%i:%s')─┐
│                                       2025-01-04 23:00:00 │
└───────────────────────────────────────────────────────────┘
```

<div id="parseDateTime32BestEffort">
  ## parseDateTime32BestEffort
</div>

도입 버전: v20.9.0

날짜 및 시간의 문자열 표현을 [`DateTime`](/ko/reference/data-types/datetime) 데이터 타입으로 변환합니다.

이 함수는 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), [RFC 1123 - 5.2.14 RFC-822 Date and Time Specification](https://tools.ietf.org/html/rfc1123#page-55), ClickHouse 및 기타 일부 날짜/시간 포맷을 파싱합니다.

**구문**

```sql theme={null}
parseDateTime32BestEffort(time_string[, time_zone])
```

**인수**

* `time_string` — 변환할 날짜 및 시간이 들어 있는 String입니다. [`String`](/ko/reference/data-types/string)
* `time_zone` — 선택 사항입니다. `time_string`을 해석할 때 기준이 되는 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`time_string`을 `DateTime`으로 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime32BestEffort('23/10/2025 12:12:57')
AS parseDateTime32BestEffort
```

```response title=Response theme={null}
┌─parseDateTime32BestEffort─┐
│       2025-10-23 12:12:57 │
└───────────────────────────┘
```

**시간대 포함**

```sql title=Query theme={null}
SELECT parseDateTime32BestEffort('Sat, 18 Aug 2025 07:22:16 GMT', 'Asia/Istanbul')
AS parseDateTime32BestEffort
```

```response title=Response theme={null}
┌─parseDateTime32BestEffort─┐
│       2025-08-18 10:22:16 │
└───────────────────────────┘
```

**Unix timestamp**

```sql title=Query theme={null}
SELECT parseDateTime32BestEffort('1284101485')
AS parseDateTime32BestEffort
```

```response title=Response theme={null}
┌─parseDateTime32BestEffort─┐
│       2015-07-07 12:04:41 │
└───────────────────────────┘
```

<div id="parseDateTime32BestEffortOrNull">
  ## parseDateTime32BestEffortOrNull
</div>

도입 버전: v20.9.0

처리할 수 없는 날짜 포맷을 만나면 `NULL`을 반환한다는 점만 제외하면 [`parseDateTime32BestEffort`](#parseDateTime32BestEffort)와 동일합니다.

**구문**

```sql theme={null}
parseDateTime32BestEffortOrNull(time_string[, time_zone])
```

**인수**

* `time_string` — 변환할 날짜와 시간이 포함된 String입니다. [`String`](/ko/reference/data-types/string)
* `time_zone` — 선택 사항입니다. `time_string`을 파싱할 때 기준이 되는 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

문자열에서 파싱한 `DateTime` 객체를 반환합니다. 파싱에 실패하면 `NULL`을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    parseDateTime32BestEffortOrNull('23/10/2025 12:12:57') AS valid,
    parseDateTime32BestEffortOrNull('invalid date') AS invalid
```

```response title=Response theme={null}
┌─valid───────────────┬─invalid─┐
│ 2025-10-23 12:12:57 │    ᴺᵁᴸᴸ │
└─────────────────────┴─────────┘
```

<div id="parseDateTime32BestEffortOrZero">
  ## parseDateTime32BestEffortOrZero
</div>

도입 버전: v20.9.0

처리할 수 없는 날짜 포맷을 만나면 제로 날짜 또는 제로 날짜/시간을 반환한다는 점을 제외하면 [`parseDateTime32BestEffort`](#parseDateTime32BestEffort)와 동일합니다.

**구문**

```sql theme={null}
parseDateTime32BestEffortOrZero(time_string[, time_zone])
```

**인수**

* `time_string` — 변환할 날짜와 시간이 포함된 문자열입니다. [`String`](/ko/reference/data-types/string)
* `time_zone` — 선택 사항입니다. `time_string`을 파싱할 때 사용할 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

문자열에서 파싱된 `DateTime` 객체를 반환합니다. 파싱에 실패하면 제로 날짜(`1970-01-01 00:00:00`)를 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    parseDateTime32BestEffortOrZero('23/10/2025 12:12:57') AS valid,
    parseDateTime32BestEffortOrZero('invalid date') AS invalid
```

```response title=Response theme={null}
┌─valid───────────────┬─invalid─────────────┐
│ 2025-10-23 12:12:57 │ 1970-01-01 00:00:00 │
└─────────────────────┴─────────────────────┘
```

<div id="parseDateTime64">
  ## parseDateTime64
</div>

도입 버전: v24.11.0

MySQL 날짜 포맷 문자열에 따라 초 미만 정밀도를 포함한 날짜 및 시간 문자열을 파싱합니다.

이 함수는 DateTime64용 [`formatDateTime`](/ko/reference/functions/regular-functions/date-time-functions)의 역함수입니다.
포맷 String을 사용해 String 인수를 파싱합니다. 1900년부터 2299년까지의 날짜를 초 미만 정밀도로 표현할 수 있는 DateTime64 유형을 반환합니다.

**구문**

```sql theme={null}
parseDateTime64(time_string, format[, timezone])
```

**인수**

* `time_string` — DateTime64로 파싱할 문자열입니다. [`String`](/ko/reference/data-types/string)
* `format` — `time_string`을 어떻게 파싱할지 지정하는 포맷 문자열입니다. [`String`](/ko/reference/data-types/string)
* `timezone` — 선택 사항입니다. 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

MySQL 스타일 포맷 문자열에 따라 입력 문자열을 파싱한 DateTime64를 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime64('2025-01-04 23:00:00.123', '%Y-%m-%d %H:%i:%s.%f')
```

```response title=Response theme={null}
┌─parseDateTime64('2025-01-04 23:00:00.123', '%Y-%m-%d %H:%i:%s.%f')─┐
│                                       2025-01-04 23:00:00.123       │
└─────────────────────────────────────────────────────────────────────┘
```

<div id="parseDateTime64BestEffort">
  ## parseDateTime64BestEffort
</div>

도입 버전: v20.1.0

[`parseDateTimeBestEffort`](#parseDateTimeBestEffort) 함수와 같지만, 밀리초와 마이크로초도 파싱하며 [`DateTime64`](/ko/reference/data-types/datetime64) 데이터 타입을 반환합니다.

**구문**

```sql theme={null}
parseDateTime64BestEffort(time_string[, precision[, time_zone]])
```

**인수**

* `time_string` — 변환할 날짜 또는 날짜와 시간이 포함된 String입니다. [`String`](/ko/reference/data-types/string)
* `precision` — 선택 사항입니다. 필요한 정밀도입니다. 밀리초는 `3`, 마이크로초는 `6`입니다. 기본값: `3`. [`UInt8`](/ko/reference/data-types/int-uint)
* `time_zone` — 선택 사항입니다. 시간대입니다. 함수는 해당 시간대에 따라 `time_string`을 파싱합니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`time_string`을 [`DateTime64`](/ko/reference/data-types/datetime64) 데이터 타입으로 변환한 값을 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime64BestEffort('2025-01-01') AS a, toTypeName(a) AS t
UNION ALL
SELECT parseDateTime64BestEffort('2025-01-01 01:01:00.12346') AS a, toTypeName(a) AS t
UNION ALL
SELECT parseDateTime64BestEffort('2025-01-01 01:01:00.12346',6) AS a, toTypeName(a) AS t
UNION ALL
SELECT parseDateTime64BestEffort('2025-01-01 01:01:00.12346',3,'Asia/Istanbul') AS a, toTypeName(a) AS t
FORMAT PrettyCompactMonoBlock
```

```response title=Response theme={null}
┌──────────────────────────a─┬─t──────────────────────────────┐
│ 2025-01-01 01:01:00.123000 │ DateTime64(3)                  │
│ 2025-01-01 00:00:00.000000 │ DateTime64(3)                  │
│ 2025-01-01 01:01:00.123460 │ DateTime64(6)                  │
│ 2025-12-31 22:01:00.123000 │ DateTime64(3, 'Asia/Istanbul') │
└────────────────────────────┴────────────────────────────────┘
```

<div id="parseDateTime64BestEffortOrNull">
  ## parseDateTime64BestEffortOrNull
</div>

도입 버전: v20.1.0

처리할 수 없는 날짜 포맷이 입력되면 `NULL`을 반환한다는 점만 제외하면 [`parseDateTime64BestEffort`](#parseDateTime64BestEffort)와 동일합니다.

**구문**

```sql theme={null}
parseDateTime64BestEffortOrNull(time_string[, precision[, time_zone]])
```

**인수**

* `time_string` — 변환할 날짜 또는 날짜와 시간이 포함된 String입니다. [`String`](/ko/reference/data-types/string)
* `precision` — 선택 사항입니다. 필요한 정밀도입니다. 밀리초는 `3`, 마이크로초는 `6`입니다. 기본값은 `3`입니다. [`UInt8`](/ko/reference/data-types/int-uint)
* `time_zone` — 선택 사항입니다. 시간대입니다. 이 함수는 해당 시간대에 따라 `time_string`을 파싱합니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`time_string`을 [`DateTime64`](/ko/reference/data-types/datetime64)로 변환한 값을 반환합니다. 입력을 파싱할 수 없으면 `NULL`을 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime64BestEffortOrNull('2025-01-01 01:01:00.123') AS valid,
       parseDateTime64BestEffortOrNull('invalid') AS invalid
```

```response title=Response theme={null}
┌─valid───────────────────┬─invalid─┐
│ 2025-01-01 01:01:00.123 │    ᴺᵁᴸᴸ │
└─────────────────────────┴─────────┘
```

<div id="parseDateTime64BestEffortOrZero">
  ## parseDateTime64BestEffortOrZero
</div>

도입 버전: v20.1.0

처리할 수 없는 날짜 포맷을 만나면 제로 날짜 또는 제로 날짜-시간 값을 반환한다는 점을 제외하면 [`parseDateTime64BestEffort`](#parseDateTime64BestEffort)와 동일합니다.

**구문**

```sql theme={null}
parseDateTime64BestEffortOrZero(time_string[, precision[, time_zone]])
```

**인수**

* `time_string` — 변환할 날짜 또는 날짜와 시간이 포함된 String입니다. [`String`](/ko/reference/data-types/string)
* `precision` — 선택 사항입니다. 필요한 정밀도입니다. 밀리초는 `3`, 마이크로초는 `6`입니다. 기본값은 `3`입니다. [`UInt8`](/ko/reference/data-types/int-uint)
* `time_zone` — 선택 사항입니다. 시간대입니다. 함수는 시간대에 따라 `time_string`을 파싱합니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`time_string`을 [`DateTime64`](/ko/reference/data-types/datetime64)로 변환한 값을 반환합니다. 입력을 파싱할 수 없으면 제로 날짜/날짜시간 값(`1970-01-01 00:00:00.000`)을 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime64BestEffortOrZero('2025-01-01 01:01:00.123') AS valid,
       parseDateTime64BestEffortOrZero('invalid') AS invalid
```

```response title=Response theme={null}
┌─valid───────────────────┬─invalid─────────────────┐
│ 2025-01-01 01:01:00.123 │ 1970-01-01 00:00:00.000 │
└─────────────────────────┴─────────────────────────┘
```

<div id="parseDateTime64BestEffortUS">
  ## parseDateTime64BestEffortUS
</div>

도입 버전: v22.8.0

[`parseDateTime64BestEffort`](#parseDateTime64BestEffort)와 동일하지만, 날짜가 모호한 경우에는 미국식 날짜 형식(`MM/DD/YYYY` 등)을 우선 적용합니다.

**구문**

```sql theme={null}
parseDateTime64BestEffortUS(time_string [, precision [, time_zone]])
```

**인수**

* `time_string` — 변환할 날짜 또는 날짜와 시간이 들어 있는 문자열입니다. [`String`](/ko/reference/data-types/string)
* `precision` — 선택 사항입니다. 필요한 정밀도입니다. 밀리초는 `3`, 마이크로초는 `6`입니다. 기본값: `3`입니다. [`UInt8`](/ko/reference/data-types/int-uint)
* `time_zone` — 선택 사항입니다. 시간대입니다. 함수는 해당 시간대에 따라 `time_string`을 해석합니다. [`String`](/ko/reference/data-types/string)

**반환 값**

모호한 경우 미국식 날짜 형식을 우선 적용하여 `time_string`을 [`DateTime64`](/ko/reference/data-types/datetime64)로 변환해 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime64BestEffortUS('02/10/2025 12:30:45.123') AS us_format,
       parseDateTime64BestEffortUS('15/08/2025 10:15:30.456') AS fallback_to_standard
```

```response title=Response theme={null}
┌─us_format───────────────┬─fallback_to_standard────┐
│ 2025-02-10 12:30:45.123 │ 2025-08-15 10:15:30.456 │
└─────────────────────────┴─────────────────────────┘
```

<div id="parseDateTime64BestEffortUSOrNull">
  ## parseDateTime64BestEffortUSOrNull
</div>

도입 버전: v22.8.0

[`parseDateTime64BestEffort`](#parseDateTime64BestEffort)와 동일하지만, 이 함수는 날짜 형식이 모호할 때 미국식 날짜 형식(`MM/DD/YYYY` 등)을 우선 적용하며, 처리할 수 없는 날짜 형식을 만나면 `NULL`을 반환합니다.

**구문**

```sql theme={null}
parseDateTime64BestEffortUSOrNull(time_string[, precision[, time_zone]])
```

**인수**

* `time_string` — 변환할 날짜 또는 시간이 포함된 날짜를 담고 있는 String입니다. [`String`](/ko/reference/data-types/string)
* `precision` — 선택 사항입니다. 필요한 정밀도입니다. 밀리초는 `3`, 마이크로초는 `6`입니다. 기본값은 `3`입니다. [`UInt8`](/ko/reference/data-types/int-uint)
* `time_zone` — 선택 사항입니다. 시간대입니다. 이 함수는 해당 시간대에 따라 `time_string`을 파싱합니다. [`String`](/ko/reference/data-types/string)

**반환 값**

US 포맷 우선순위를 사용해 `time_string`을 [`DateTime64`](/ko/reference/data-types/datetime64)로 변환한 값을 반환합니다. 입력을 파싱할 수 없으면 `NULL`을 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime64BestEffortUSOrNull('02/10/2025 12:30:45.123') AS valid_us,
       parseDateTime64BestEffortUSOrNull('invalid') AS invalid
```

```response title=Response theme={null}
┌─valid_us────────────────┬─invalid─┐
│ 2025-02-10 12:30:45.123 │    ᴺᵁᴸᴸ │
└─────────────────────────┴─────────┘
```

<div id="parseDateTime64BestEffortUSOrZero">
  ## parseDateTime64BestEffortUSOrZero
</div>

도입 버전: v22.8.0

[`parseDateTime64BestEffort`](#parseDateTime64BestEffort)와 동일하지만, 날짜 형식이 모호할 때는 미국식 날짜 형식(`MM/DD/YYYY` 등)을 우선하며, 처리할 수 없는 날짜 포맷을 만나면 제로 날짜 또는 제로 날짜 시간(date time)을 반환합니다.

**구문**

```sql theme={null}
parseDateTime64BestEffortUSOrZero(time_string [, precision [, time_zone]])
```

**인수**

* `time_string` — 변환할 날짜 또는 날짜와 시간이 포함된 문자열입니다. [`String`](/ko/reference/data-types/string)
* `precision` — 선택 사항입니다. 필요한 정밀도입니다. 밀리초는 `3`, 마이크로초는 `6`입니다. 기본값은 `3`입니다. [`UInt8`](/ko/reference/data-types/int-uint)
* `time_zone` — 선택 사항입니다. 시간대입니다. 함수는 `time_string`을 이 시간대에 따라 파싱합니다. [`String`](/ko/reference/data-types/string)

**반환 값**

미국식 포맷을 우선 적용하여 `time_string`을 [`DateTime64`](/ko/reference/data-types/datetime64)로 변환한 값을 반환합니다. 입력을 파싱할 수 없으면 제로 날짜/날짜시간(`1970-01-01 00:00:00.000`)을 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime64BestEffortUSOrZero('02/10/2025 12:30:45.123') AS valid_us,
       parseDateTime64BestEffortUSOrZero('invalid') AS invalid
```

```response title=Response theme={null}
┌─valid_us────────────────┬─invalid─────────────────┐
│ 2025-02-10 12:30:45.123 │ 1970-01-01 00:00:00.000 │
└─────────────────────────┴─────────────────────────┘
```

<div id="parseDateTime64InJodaSyntax">
  ## parseDateTime64InJodaSyntax
</div>

도입 버전: v24.10.0

Joda 날짜 포맷 문자열에 따라 초 미만 정밀도를 포함하는 날짜 및 시간 문자열을 파싱합니다.

이 함수는 DateTime64용 [`formatDateTimeInJodaSyntax`](/ko/reference/functions/regular-functions/date-time-functions#formatDateTimeInJodaSyntax)의 역함수입니다.
Joda 스타일의 포맷 `String`을 사용해 `String` 인수를 파싱합니다. 반환값은 초 미만 정밀도로 1900년부터 2299년까지의 날짜를 표현할 수 있는 DateTime64 유형입니다.

포맷 패턴은 [Joda Time documentation](https://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html)을 참조하십시오.

**구문**

```sql theme={null}
parseDateTime64InJodaSyntax(time_string, format[, timezone])
```

**인수**

* `time_string` — DateTime64로 파싱할 String입니다. [`String`](/ko/reference/data-types/string)
* `format` — `time_string`를 파싱하는 방법을 지정하는 Joda 문법의 포맷 문자열입니다. [`String`](/ko/reference/data-types/string)
* `timezone` — 선택 사항입니다. 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

Joda 스타일 포맷 문자열에 따라 입력 문자열을 파싱한 DateTime64를 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime64InJodaSyntax('2025-01-04 23:00:00.123', 'yyyy-MM-dd HH:mm:ss.SSS')
```

```response title=Response theme={null}
┌─parseDateTime64InJodaSyntax('2025-01-04 23:00:00.123', 'yyyy-MM-dd HH:mm:ss.SSS')─┐
│                                                          2025-01-04 23:00:00.123   │
└────────────────────────────────────────────────────────────────────────────────────┘
```

<div id="parseDateTime64InJodaSyntaxOrNull">
  ## parseDateTime64InJodaSyntaxOrNull
</div>

도입 버전: v24.10.0

[`parseDateTime64InJodaSyntax`](#parseDateTime64InJodaSyntax)와 동일하지만, 구문 분석할 수 없는 날짜 포맷을 만나면 `NULL`을 반환합니다.

**구문**

```sql theme={null}
parseDateTime64InJodaSyntaxOrNull(time_string, format[, timezone])
```

**인수**

* `time_string` — DateTime64로 파싱할 문자열입니다. [`String`](/ko/reference/data-types/string)
* `format` — `time_string`을 파싱하는 방법을 지정하는 Joda 문법의 포맷 문자열입니다. [`String`](/ko/reference/data-types/string)
* `timezone` — 선택 사항입니다. 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

입력 문자열에서 파싱한 DateTime64를 반환합니다. 파싱에 실패하면 NULL을 반환합니다. [`Nullable(DateTime64)`](/ko/reference/data-types/nullable)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime64InJodaSyntaxOrNull('2025-01-04 23:00:00.123', 'yyyy-MM-dd HH:mm:ss.SSS')
```

```response title=Response theme={null}
┌─parseDateTime64InJodaSyntaxOrNull('2025-01-04 23:00:00.123', 'yyyy-MM-dd HH:mm:ss.SSS')─┐
│                                                             2025-01-04 23:00:00.123      │
└──────────────────────────────────────────────────────────────────────────────────────────┘
```

<div id="parseDateTime64InJodaSyntaxOrZero">
  ## parseDateTime64InJodaSyntaxOrZero
</div>

도입 버전: v24.10.0

[`parseDateTime64InJodaSyntax`](#parseDateTime64InJodaSyntax)와 동일하지만, 해석할 수 없는 날짜 포맷을 만나면 제로 날짜를 반환합니다.

**구문**

```sql theme={null}
parseDateTime64InJodaSyntaxOrZero(time_string, format[, timezone])
```

**인수**

* `time_string` — DateTime64로 파싱할 문자열입니다. [`String`](/ko/reference/data-types/string)
* `format` — `time_string`을 파싱하는 방법을 지정하는 Joda 문법 포맷 문자열입니다. [`String`](/ko/reference/data-types/string)
* `timezone` — 선택 사항입니다. 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

입력 문자열에서 파싱한 DateTime64를 반환합니다. 파싱에 실패하면 제로 DateTime64를 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime64InJodaSyntaxOrZero('2025-01-04 23:00:00.123', 'yyyy-MM-dd HH:mm:ss.SSS')
```

```response title=Response theme={null}
┌─parseDateTime64InJodaSyntaxOrZero('2025-01-04 23:00:00.123', 'yyyy-MM-dd HH:mm:ss.SSS')─┐
│                                                              2025-01-04 23:00:00.123     │
└──────────────────────────────────────────────────────────────────────────────────────────┘
```

<div id="parseDateTime64OrNull">
  ## parseDateTime64OrNull
</div>

도입 버전: v24.11.0

[`parseDateTime64`](#parseDateTime64)와 동일하지만, 파싱할 수 없는 날짜 포맷을 만나면 `NULL`을 반환합니다.

**구문**

```sql theme={null}
parseDateTime64OrNull(time_string, format[, timezone])
```

**인수**

* `time_string` — DateTime64로 파싱할 문자열입니다. [`String`](/ko/reference/data-types/string)
* `format` — `time_string`을 파싱하는 방법을 지정하는 포맷 문자열입니다. [`String`](/ko/reference/data-types/string)
* `timezone` — 선택 사항인 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

입력 문자열에서 파싱한 DateTime64를 반환합니다. 파싱에 실패하면 NULL을 반환합니다. [`Nullable(DateTime64)`](/ko/reference/data-types/nullable)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime64OrNull('2025-01-04 23:00:00.123', '%Y-%m-%d %H:%i:%s.%f')
```

```response title=Response theme={null}
┌─parseDateTime64OrNull('2025-01-04 23:00:00.123', '%Y-%m-%d %H:%i:%s.%f')─┐
│                                            2025-01-04 23:00:00.123        │
└───────────────────────────────────────────────────────────────────────────┘
```

<div id="parseDateTime64OrZero">
  ## parseDateTime64OrZero
</div>

도입 버전: v24.11.0

[`parseDateTime64`](#parseDateTime64)와 같지만, 파싱할 수 없는 날짜 포맷을 만나면 제로 날짜를 반환합니다.

**구문**

```sql theme={null}
parseDateTime64OrZero(time_string, format[, timezone])
```

**인수**

* `time_string` — DateTime64로 파싱할 `String`입니다. [`String`](/ko/reference/data-types/string)
* `format` — time\_string을 어떻게 파싱할지 지정하는 포맷 문자열입니다. [`String`](/ko/reference/data-types/string)
* `timezone` — 선택 사항입니다. 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

입력 문자열에서 파싱한 DateTime64를 반환합니다. 파싱에 실패하면 제로 DateTime64를 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTime64OrZero('2025-01-04 23:00:00.123', '%Y-%m-%d %H:%i:%s.%f')
```

```response title=Response theme={null}
┌─parseDateTime64OrZero('2025-01-04 23:00:00.123', '%Y-%m-%d %H:%i:%s.%f')─┐
│                                             2025-01-04 23:00:00.123       │
└───────────────────────────────────────────────────────────────────────────┘
```

<div id="parseDateTimeBestEffort">
  ## parseDateTimeBestEffort
</div>

도입 버전: v1.1.0

String 형식의 날짜 및 시간을 DateTime 데이터 타입으로 변환합니다.
이 함수는 [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html), [RFC 1123 - 5.2.14 RFC-822](https://datatracker.ietf.org/doc/html/rfc822) Date and Time Specification, ClickHouse 및 일부 다른 날짜/시간 포맷을 파싱합니다.

지원되는 비표준 포맷:

* 9\~10자리 Unix 타임스탬프를 포함하는 문자열
* 날짜와 시간 구성 요소를 포함하는 문자열: `YYYYMMDDhhmmss`, `DD/MM/YYYY hh:mm:ss`, `DD-MM-YY hh:mm`, `YYYY-MM-DD hh:mm:ss` 등
* 날짜는 있지만 시간 구성 요소는 없는 문자열: `YYYY`, `YYYYMM`, `YYYY*MM`, `DD/MM/YYYY`, `DD-MM-YY` 등
* 일(day)과 시간을 포함하는 문자열: `DD`, `DD hh`, `DD hh:mm`. 이 경우 `MM`은 `01`로 대체됩니다.
* 날짜와 시간에 시간대 오프셋 정보가 함께 포함된 문자열: `YYYY-MM-DD hh:mm:ss ±h:mm` 등
* syslog 타임스탬프: `Mmm dd hh:mm:ss`. 예: `Jun  9 14:20:32`

구분자가 있는 모든 포맷에 대해 이 함수는 월 이름의 전체 표기 또는 앞 3글자로 표기된 월 이름을 파싱합니다.
연도가 지정되지 않으면 현재 연도로 간주됩니다.

**구문**

```sql theme={null}
parseDateTimeBestEffort(time_string[, time_zone])
```

**인수**

* `time_string` — 변환할 날짜와 시간이 들어 있는 `String`입니다. [`String`](/ko/reference/data-types/string)
* `time_zone` — 선택 사항입니다. `time_string`을 파싱할 때 사용할 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`time_string`을 `DateTime`으로 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTimeBestEffort('23/10/2025 12:12:57') AS parseDateTimeBestEffort
```

```response title=Response theme={null}
┌─parseDateTimeBestEffort─┐
│     2025-10-23 12:12:57 │
└─────────────────────────┘
```

**시간대 포함**

```sql title=Query theme={null}
SELECT parseDateTimeBestEffort('Sat, 18 Aug 2025 07:22:16 GMT', 'Asia/Istanbul') AS parseDateTimeBestEffort
```

```response title=Response theme={null}
┌─parseDateTimeBestEffort─┐
│     2025-08-18 10:22:16 │
└─────────────────────────┘
```

**Unix 타임스탬프**

```sql title=Query theme={null}
SELECT parseDateTimeBestEffort('1735689600') AS parseDateTimeBestEffort
```

```response title=Response theme={null}
┌─parseDateTimeBestEffort─┐
│     2025-01-01 00:00:00 │
└─────────────────────────┘
```

<div id="parseDateTimeBestEffortOrNull">
  ## parseDateTimeBestEffortOrNull
</div>

도입 버전: v1.1.0

[`parseDateTimeBestEffort`](#parseDateTimeBestEffort)와 동일하지만, 처리할 수 없는 날짜 포맷을 만나면 `NULL`을 반환합니다.
이 함수는 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), [RFC 1123 - 5.2.14 RFC-822 Date and Time Specification](https://tools.ietf.org/html/rfc1123#page-55), ClickHouse 포맷과 그 밖의 일부 날짜 및 시간 포맷을 파싱합니다.

지원되는 비표준 포맷:

* 9\~10자리 Unix timestamp를 포함하는 문자열.
* 날짜 및 시간 component를 포함하는 문자열: `YYYYMMDDhhmmss`, `DD/MM/YYYY hh:mm:ss`, `DD-MM-YY hh:mm`, `YYYY-MM-DD hh:mm:ss` 등.
* 날짜는 있지만 시간 component는 없는 문자열: `YYYY`, `YYYYMM`, `YYYY*MM`, `DD/MM/YYYY`, `DD-MM-YY` 등.
* 일과 시간이 포함된 문자열: `DD`, `DD hh`, `DD hh:mm`. 이 경우 `MM`은 `01`로 대체됩니다.
* 날짜와 시간에 time zone 오프셋 정보까지 포함된 문자열: `YYYY-MM-DD hh:mm:ss ±h:mm` 등.
* syslog timestamp: `Mmm dd hh:mm:ss`. 예: `Jun  9 14:20:32`.

구분자가 있는 모든 포맷에서 이 함수는 월 이름 전체 또는 앞 3글자로 표기된 월 이름을 파싱합니다.
연도가 지정되지 않은 경우 현재 연도로 간주됩니다.

**구문**

```sql theme={null}
parseDateTimeBestEffortOrNull(time_string[, time_zone])
```

**인수**

* `time_string` — 변환할 날짜와 시간이 포함된 String입니다. [`String`](/ko/reference/data-types/string)
* `time_zone` — 선택 사항입니다. `time_string`을 파싱할 때 기준으로 사용할 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`time_string`을 DateTime으로 반환합니다. 입력을 파싱할 수 없으면 `NULL`을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTimeBestEffortOrNull('23/10/2025 12:12:57') AS valid,
       parseDateTimeBestEffortOrNull('invalid') AS invalid
```

```response title=Response theme={null}
┌─valid───────────────┬─invalid─┐
│ 2025-10-23 12:12:57 │    ᴺᵁᴸᴸ │
└─────────────────────┴─────────┘
```

<div id="parseDateTimeBestEffortOrZero">
  ## parseDateTimeBestEffortOrZero
</div>

도입 버전: v1.1.0

처리할 수 없는 날짜 포맷을 만나면 제로 날짜 또는 제로 날짜 시간을 반환한다는 점을 제외하면 [`parseDateTimeBestEffort`](#parseDateTimeBestEffort)와 동일합니다.
이 함수는 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601), [RFC 1123 - 5.2.14 RFC-822 Date and Time Specification](https://tools.ietf.org/html/rfc1123#page-55), ClickHouse 및 기타 일부 날짜/시간 포맷을 파싱합니다.

지원되는 비표준 포맷:

* 9\~10자리 Unix timestamp를 포함하는 문자열.
* 날짜와 시간 구성 요소를 포함하는 문자열: `YYYYMMDDhhmmss`, `DD/MM/YYYY hh:mm:ss`, `DD-MM-YY hh:mm`, `YYYY-MM-DD hh:mm:ss` 등.
* 날짜는 있지만 시간 구성 요소는 없는 문자열: `YYYY`, `YYYYMM`, `YYYY*MM`, `DD/MM/YYYY`, `DD-MM-YY` 등.
* 일과 시간이 포함된 문자열: `DD`, `DD hh`, `DD hh:mm`. 이 경우 `MM`은 `01`로 대체됩니다.
* 날짜와 시간에 time zone 오프셋 정보가 함께 포함된 문자열: `YYYY-MM-DD hh:mm:ss ±h:mm` 등.
* syslog timestamp: `Mmm dd hh:mm:ss`. 예: `Jun  9 14:20:32`.

구분자가 있는 모든 포맷에서 이 함수는 월 이름의 전체 표기 또는 앞 3글자로 표기된 월 이름을 파싱합니다.
연도가 지정되지 않으면 현재 연도로 간주됩니다.

**구문**

```sql theme={null}
parseDateTimeBestEffortOrZero(time_string[, time_zone])
```

**인수**

* `time_string` — 변환할 날짜 및 시간이 포함된 String입니다. [`String`](/ko/reference/data-types/string)
* `time_zone` — 선택 사항입니다. `time_string`을 파싱할 때 기준이 되는 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`time_string`을 `DateTime`으로 반환합니다. 입력을 파싱할 수 없으면 제로 날짜/날짜-시간(`1970-01-01` 또는 `1970-01-01 00:00:00`)을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTimeBestEffortOrZero('23/10/2025 12:12:57') AS valid,
       parseDateTimeBestEffortOrZero('invalid') AS invalid
```

```response title=Response theme={null}
┌─valid───────────────┬─invalid─────────────┐
│ 2025-10-23 12:12:57 │ 1970-01-01 00:00:00 │
└─────────────────────┴─────────────────────┘
```

<div id="parseDateTimeBestEffortUS">
  ## parseDateTimeBestEffortUS
</div>

도입 버전: v1.1.0

이 함수는 ISO 날짜 포맷(예: `YYYY-MM-DD hh:mm:ss`)과 월 및 일 구성 요소를 모호함 없이 추출할 수 있는 다른 날짜 포맷(예: `YYYYMMDDhhmmss`, `YYYY-MM`, `DD hh`, `YYYY-MM-DD hh:mm:ss ±h:mm`)에 대해서는 [`parseDateTimeBestEffort`](#parseDateTimeBestEffort)와 동일하게 동작합니다.
월과 일 구성 요소를 모호함 없이 추출할 수 없는 경우(예: `MM/DD/YYYY`, `MM-DD-YYYY`, `MM-DD-YY`)에는 `DD/MM/YYYY`, `DD-MM-YYYY`, `DD-MM-YY` 대신 미국식 날짜 형식을 우선 적용합니다.
앞 문장의 예외로, 월이 12보다 크고 31보다 작거나 같은 경우에는 이 함수가 [`parseDateTimeBestEffort`](#parseDateTimeBestEffort)의 동작으로 되돌아가며, 예를 들어 `15/08/2020`은 `2020-08-15`로 파싱됩니다.

**구문**

```sql theme={null}
parseDateTimeBestEffortUS(time_string[, time_zone])
```

**인수**

* `time_string` — 변환할 날짜 및 시간이 포함된 String입니다. [`String`](/ko/reference/data-types/string)
* `time_zone` — 선택 사항입니다. `time_string`을 파싱할 때 기준으로 사용할 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

모호한 경우에는 미국식 날짜 형식을 우선 적용해 `time_string`을 `DateTime`으로 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTimeBestEffortUS('02/10/2025') AS us_format,
       parseDateTimeBestEffortUS('15/08/2025') AS fallback_to_standard
```

```response title=Response theme={null}
┌─us_format───────────┬─fallback_to_standard─┐
│ 2025-02-10 00:00:00 │  2025-08-15 00:00:00 │
└─────────────────────┴──────────────────────┘
```

<div id="parseDateTimeBestEffortUSOrNull">
  ## parseDateTimeBestEffortUSOrNull
</div>

도입 버전: v1.1.0

처리할 수 없는 날짜 포맷을 만나면 `NULL`을 반환한다는 점만 제외하면 [`parseDateTimeBestEffortUS`](#parseDateTimeBestEffortUS) 함수와 동일합니다.

이 함수는 ISO 날짜 포맷에서는 [`parseDateTimeBestEffort`](#parseDateTimeBestEffort)처럼 동작하지만, 모호한 경우에는 미국식 날짜 형식을 우선 적용하며, 파싱 오류가 발생하면 `NULL`을 반환합니다.

**구문**

```sql theme={null}
parseDateTimeBestEffortUSOrNull(time_string[, time_zone])
```

**인수**

* `time_string` — 변환할 날짜와 시간이 포함된 String입니다. [`String`](/ko/reference/data-types/string)
* `time_zone` — 선택 사항입니다. `time_string`을 파싱할 때 기준이 되는 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`time_string`을 미국식 포맷을 우선하여 DateTime으로 반환합니다. 입력을 파싱할 수 없으면 `NULL`을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTimeBestEffortUSOrNull('02/10/2025') AS valid_us,
       parseDateTimeBestEffortUSOrNull('invalid') AS invalid
```

```response title=Response theme={null}
┌─valid_us────────────┬─invalid─┐
│ 2025-02-10 00:00:00 │    ᴺᵁᴸᴸ │
└─────────────────────┴─────────┘
```

<div id="parseDateTimeBestEffortUSOrZero">
  ## parseDateTimeBestEffortUSOrZero
</div>

출시 버전: v1.1.0

처리할 수 없는 날짜 포맷을 만나면 제로 날짜 (`1970-01-01`) 또는 시간이 포함된 제로 날짜 (`1970-01-01 00:00:00`)를 반환한다는 점을 제외하면 [`parseDateTimeBestEffortUS`](#parseDateTimeBestEffortUS) 함수와 동일합니다.

이 함수는 ISO 날짜 포맷에서는 [`parseDateTimeBestEffort`](#parseDateTimeBestEffort)와 동일하게 동작하지만, 모호한 경우에는 US date format을 우선 적용하며, 파싱 오류가 발생하면 제로 날짜 값을 반환합니다.

**구문**

```sql theme={null}
parseDateTimeBestEffortUSOrZero(time_string[, time_zone])
```

**인수**

* `time_string` — 변환할 날짜 및 시간이 포함된 String입니다. [`String`](/ko/reference/data-types/string)
* `time_zone` — 선택 사항입니다. `time_string`을 파싱할 때 기준이 되는 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

미국식 포맷을 우선하여 `time_string`을 `DateTime`으로 반환합니다. 입력을 파싱할 수 없으면 제로 날짜/날짜 및 시간(`1970-01-01` 또는 `1970-01-01 00:00:00`)을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTimeBestEffortUSOrZero('02/10/2025') AS valid_us,
       parseDateTimeBestEffortUSOrZero('invalid') AS invalid
```

```response title=Response theme={null}
┌─valid_us────────────┬─invalid─────────────┐
│ 2025-02-10 00:00:00 │ 1970-01-01 00:00:00 │
└─────────────────────┴─────────────────────┘
```

<div id="parseDateTimeInJodaSyntax">
  ## parseDateTimeInJodaSyntax
</div>

도입 버전: v23.3.0

Joda 날짜 포맷 문자열에 따라 날짜 및 시간 문자열을 파싱합니다.

이 함수는 [`formatDateTimeInJodaSyntax`](/ko/reference/functions/regular-functions/date-time-functions#formatDateTimeInJodaSyntax)의 역함수입니다.
Joda 스타일 포맷 String을 사용하여 String 인수를 파싱합니다. DateTime 유형을 반환합니다.

포맷 패턴은 [Joda Time documentation](https://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html) 문서를 참조하십시오.

**구문**

```sql theme={null}
parseDateTimeInJodaSyntax(time_string, format[, timezone])
```

**인수**

* `time_string` — DateTime으로 파싱할 `String`. [`String`](/ko/reference/data-types/string)
* `format` — `time_string`을 파싱하는 방법을 지정하는 Joda 문법의 포맷 문자열. [`String`](/ko/reference/data-types/string)
* `timezone` — 선택 사항입니다. 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

Joda 스타일 포맷 문자열에 따라 입력 문자열을 파싱한 DateTime을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTimeInJodaSyntax('2025-01-04 23:00:00', 'yyyy-MM-dd HH:mm:ss')
```

```response title=Response theme={null}
┌─parseDateTimeInJodaSyntax('2025-01-04 23:00:00', 'yyyy-MM-dd HH:mm:ss')─┐
│                                                      2025-01-04 23:00:00 │
└──────────────────────────────────────────────────────────────────────────┘
```

<div id="parseDateTimeInJodaSyntaxOrNull">
  ## parseDateTimeInJodaSyntaxOrNull
</div>

도입 버전: v23.3.0

[`parseDateTimeInJodaSyntax`](#parseDateTimeInJodaSyntax)와 동일하지만, 파싱할 수 없는 날짜 포맷을 만나면 `NULL`을 반환합니다.

**구문**

```sql theme={null}
parseDateTimeInJodaSyntaxOrNull(time_string, format[, timezone])
```

**인수**

* `time_string` — DateTime으로 파싱할 문자열입니다. [`String`](/ko/reference/data-types/string)
* `format` — `time_string`을 파싱하는 방법을 지정하는 Joda 문법 포맷 문자열입니다. [`String`](/ko/reference/data-types/string)
* `timezone` — 선택 사항인 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

입력 문자열을 파싱한 DateTime을 반환합니다. 파싱에 실패하면 NULL을 반환합니다. [`Nullable(DateTime)`](/ko/reference/data-types/nullable)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTimeInJodaSyntaxOrNull('2025-01-04 23:00:00', 'yyyy-MM-dd HH:mm:ss')
```

```response title=Response theme={null}
┌─parseDateTimeInJodaSyntaxOrNull('2025-01-04 23:00:00', 'yyyy-MM-dd HH:mm:ss')─┐
│                                                         2025-01-04 23:00:00    │
└────────────────────────────────────────────────────────────────────────────────┘
```

<div id="parseDateTimeInJodaSyntaxOrZero">
  ## parseDateTimeInJodaSyntaxOrZero
</div>

도입된 버전: v23.3.0

[`parseDateTimeInJodaSyntax`](#parseDateTimeInJodaSyntax)와 동일하지만, 해석할 수 없는 날짜 포맷을 만나면 제로 날짜를 반환합니다.

**구문**

```sql theme={null}
parseDateTimeInJodaSyntaxOrZero(time_string, format[, timezone])
```

**인수**

* `time_string` — DateTime으로 파싱할 문자열입니다. [`String`](/ko/reference/data-types/string)
* `format` — `time_string`을 파싱하는 방법을 지정하는 Joda 문법의 포맷 문자열입니다. [`String`](/ko/reference/data-types/string)
* `timezone` — 선택 사항입니다. 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

입력 문자열에서 파싱한 DateTime을 반환합니다. 파싱에 실패하면 제로 DateTime을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTimeInJodaSyntaxOrZero('2025-01-04 23:00:00', 'yyyy-MM-dd HH:mm:ss')
```

```response title=Response theme={null}
┌─parseDateTimeInJodaSyntaxOrZero('2025-01-04 23:00:00', 'yyyy-MM-dd HH:mm:ss')─┐
│                                                          2025-01-04 23:00:00   │
└────────────────────────────────────────────────────────────────────────────────┘
```

<div id="parseDateTimeOrNull">
  ## parseDateTimeOrNull
</div>

도입 버전: v23.3.0

[`parseDateTime`](#parseDateTime)와 동일하지만, 파싱할 수 없는 날짜 포맷을 만나면 `NULL`을 반환합니다.

**구문**

```sql theme={null}
parseDateTimeOrNull(time_string, format[, timezone])
```

**별칭**: `str_to_date`

**인수**

* `time_string` — DateTime으로 파싱할 문자열입니다. [`String`](/ko/reference/data-types/string)
* `format` — `time_string`을 파싱하는 방법을 지정하는 포맷 문자열입니다. [`String`](/ko/reference/data-types/string)
* `timezone` — 선택 사항입니다. 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

입력 문자열에서 파싱된 DateTime을 반환합니다. 파싱에 실패하면 NULL을 반환합니다. [`Nullable(DateTime)`](/ko/reference/data-types/nullable)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTimeOrNull('2025-01-04+23:00:00', '%Y-%m-%d+%H:%i:%s')
```

```response title=Response theme={null}
┌─parseDateTimeOrNull('2025-01-04+23:00:00', '%Y-%m-%d+%H:%i:%s')─┐
│                                            2025-01-04 23:00:00  │
└─────────────────────────────────────────────────────────────────┘
```

<div id="parseDateTimeOrZero">
  ## parseDateTimeOrZero
</div>

도입 버전: v23.3.0

[`parseDateTime`](#parseDateTime)와 동일하지만, 파싱할 수 없는 날짜 포맷을 만나면 제로 날짜를 반환합니다.

**구문**

```sql theme={null}
parseDateTimeOrZero(time_string, format[, timezone])
```

**인수**

* `time_string` — DateTime으로 파싱할 문자열입니다. [`String`](/ko/reference/data-types/string)
* `format` — `time_string`을 파싱하는 방법을 지정하는 포맷 문자열입니다. [`String`](/ko/reference/data-types/string)
* `timezone` — 선택 사항입니다. 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

입력 문자열에서 파싱한 DateTime을 반환합니다. 파싱에 실패하면 제로 DateTime을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT parseDateTimeOrZero('2025-01-04+23:00:00', '%Y-%m-%d+%H:%i:%s')
```

```response title=Response theme={null}
┌─parseDateTimeOrZero('2025-01-04+23:00:00', '%Y-%m-%d+%H:%i:%s')─┐
│                                             2025-01-04 23:00:00 │
└─────────────────────────────────────────────────────────────────┘
```

<div id="reinterpret">
  ## reinterpret
</div>

도입 버전: v1.1.0

제공된 값 `x`에 대해 메모리에 있는 동일한 원본 바이트 시퀀스를 사용하여 대상 유형으로 재해석합니다.

**구문**

```sql theme={null}
reinterpret(x, type)
```

**인수**

* `x` — 모든 타입. [`Any`](/ko/reference/data-types/index)
* `type` — 대상 타입. 배열인 경우, 배열의 요소 타입은 고정 길이 타입이어야 합니다. [`String`](/ko/reference/data-types/string)

**반환 값**

대상 타입의 값입니다. [`Any`](/ko/reference/data-types/index)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT reinterpret(toInt8(-1), 'UInt8') AS int_to_uint,
    reinterpret(toInt8(1), 'Float32') AS int_to_float,
    reinterpret('1', 'UInt32') AS string_to_int
```

```response title=Response theme={null}
┌─int_to_uint─┬─int_to_float─┬─string_to_int─┐
│         255 │        1e-45 │            49 │
└─────────────┴──────────────┴───────────────┘
```

**배열 예시**

```sql title=Query theme={null}
SELECT reinterpret(x'3108b4403108d4403108b4403108d440', 'Array(Float32)') AS string_to_array_of_Float32
```

```response title=Response theme={null}
┌─string_to_array_of_Float32─┐
│ [5.626,6.626,5.626,6.626]  │
└────────────────────────────┘
```

<div id="reinterpretAsDate">
  ## reinterpretAsDate
</div>

도입 버전: v1.1.0

입력 값을 Date 값으로 재해석합니다(리틀 엔디언 순서를 가정). 이는 Unix epoch인 1970-01-01부터 경과한 일 수를 나타냅니다.

**구문**

```sql theme={null}
reinterpretAsDate(x)
```

**인수**

* `x` — Unix Epoch 시작 이후의 일수입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

Date입니다. [`Date`](/ko/reference/data-types/date)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT reinterpretAsDate(65), reinterpretAsDate('A')
```

```response title=Response theme={null}
┌─reinterpretAsDate(65)─┬─reinterpretAsDate('A')─┐
│            1970-03-07 │             1970-03-07 │
└───────────────────────┴────────────────────────┘
```

<div id="reinterpretAsDateTime">
  ## reinterpretAsDateTime
</div>

도입 버전: v1.1.0

입력 값을 DateTime 값으로 재해석합니다(리틀 엔디언 순서를 가정). 이 값은 Unix epoch인 1970-01-01 시작 이후의 일 수를 나타냅니다.

**구문**

```sql theme={null}
reinterpretAsDateTime(x)
```

**인수**

* `x` — Unix epoch 시작 시점부터 경과한 초 수입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

날짜 및 시간입니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT reinterpretAsDateTime(65), reinterpretAsDateTime('A')
```

```response title=Response theme={null}
┌─reinterpretAsDateTime(65)─┬─reinterpretAsDateTime('A')─┐
│       1970-01-01 01:01:05 │        1970-01-01 01:01:05 │
└───────────────────────────┴────────────────────────────┘
```

<div id="reinterpretAsFixedString">
  ## reinterpretAsFixedString
</div>

도입 버전: v1.1.0

입력 값을 고정 길이 문자열로 재해석합니다(리틀 엔디언 순서를 가정).
끝의 null byte는 무시됩니다. 예를 들어, 이 함수는 UInt32 값 255를 단일 문자 문자열로 반환합니다.

**구문**

```sql theme={null}
reinterpretAsFixedString(x)
```

**인수**

* `x` — 문자열로 재해석할 값. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime)

**반환 값**

`x`를 나타내는 바이트를 포함한 고정 길이 문자열입니다. [`FixedString`](/ko/reference/data-types/fixedstring)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    reinterpretAsFixedString(toDateTime('1970-01-01 01:01:05')),
    reinterpretAsFixedString(toDate('1970-03-07'))
```

```response title=Response theme={null}
┌─reinterpretAsFixedString(toDateTime('1970-01-01 01:01:05'))─┬─reinterpretAsFixedString(toDate('1970-03-07'))─┐
│ A                                                           │ A                                              │
└─────────────────────────────────────────────────────────────┴────────────────────────────────────────────────┘
```

<div id="reinterpretAsFloat32">
  ## reinterpretAsFloat32
</div>

도입 버전: v1.1.0

입력 값을 Float32 타입의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리, 이 함수는 원래 값을 유지하려고 시도하지 않습니다. 대상 타입이 입력 타입을 표현할 수 없으면 출력은 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsFloat32(x)
```

**인수**

* `x` — Float32로 재해석할 값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

`x`를 재해석한 값을 반환합니다. [`Float32`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT reinterpretAsUInt32(toFloat32(0.2)) AS x, reinterpretAsFloat32(x)
```

```response title=Response theme={null}
┌──────────x─┬─reinterpretAsFloat32(x)─┐
│ 1045220557 │                     0.2 │
└────────────┴─────────────────────────┘
```

<div id="reinterpretAsFloat64">
  ## reinterpretAsFloat64
</div>

도입 버전: v1.1.0

입력 값을 Float64 유형의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리 이 함수는 원래 값을 유지하려고 하지 않습니다. 대상 유형으로 입력 유형을 표현할 수 없는 경우, 출력 결과는 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsFloat64(x)
```

**인수**

* `x` — `Float64`로 재해석할 값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

재해석된 값 `x`를 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT reinterpretAsUInt64(toFloat64(0.2)) AS x, reinterpretAsFloat64(x)
```

```response title=Response theme={null}
┌───────────────────x─┬─reinterpretAsFloat64(x)─┐
│ 4596373779694328218 │                     0.2 │
└─────────────────────┴─────────────────────────┘
```

<div id="reinterpretAsInt128">
  ## reinterpretAsInt128
</div>

도입 버전: v1.1.0

입력 값을 Int128 유형의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리, 이 함수는 원래 값을 보존하지 않습니다. 대상 유형이 입력 유형을 표현할 수 없으면 결과는 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsInt128(x)
```

**인수**

* `x` — Int128로 다시 해석할 값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

다시 해석된 값 `x`를 반환합니다. [`Int128`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt64(257) AS x,
    toTypeName(x),
    reinterpretAsInt128(x) AS res,
    toTypeName(res)
```

```response title=Response theme={null}
┌───x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 257 │ Int64         │ 257 │ Int128          │
└─────┴───────────────┴─────┴─────────────────┘
```

<div id="reinterpretAsInt16">
  ## reinterpretAsInt16
</div>

도입 버전: v1.1.0

입력 값을 Int16 유형의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리 이 함수는 원래 값을 보존하려고 하지 않습니다. 대상 유형으로 입력 유형을 표현할 수 없으면 결과는 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsInt16(x)
```

**인수**

* `x` — Int16으로 재해석할 값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

재해석된 값 `x`를 반환합니다. [`Int16`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt8(257) AS x,
    toTypeName(x),
    reinterpretAsInt16(x) AS res,
    toTypeName(res)
```

```response title=Response theme={null}
┌─x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 1 │ Int8          │   1 │ Int16           │
└───┴───────────────┴─────┴─────────────────┘
```

<div id="reinterpretAsInt256">
  ## reinterpretAsInt256
</div>

도입 버전: v1.1.0

입력 값을 Int256 유형의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리, 이 함수는 원래 값을 보존하려고 하지 않습니다. 대상 유형으로 입력 유형을 표현할 수 없으면 출력은 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsInt256(x)
```

**인수**

* `x` — Int256으로 재해석할 값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

재해석된 값 `x`를 반환합니다. [`Int256`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt128(257) AS x,
    toTypeName(x),
    reinterpretAsInt256(x) AS res,
    toTypeName(res)
```

```response title=Response theme={null}
┌───x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 257 │ Int128        │ 257 │ Int256          │
└─────┴───────────────┴─────┴─────────────────┘
```

<div id="reinterpretAsInt32">
  ## reinterpretAsInt32
</div>

도입 버전: v1.1.0

입력 값을 Int32 유형의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리, 이 함수는 원래 값을 보존하지 않습니다. 대상 유형으로 입력 유형을 표현할 수 없으면 출력은 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsInt32(x)
```

**인수**

* `x` — Int32로 재해석할 값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

재해석된 값 `x`를 반환합니다. [`Int32`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt16(257) AS x,
    toTypeName(x),
    reinterpretAsInt32(x) AS res,
    toTypeName(res)
```

```response title=Response theme={null}
┌───x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 257 │ Int16         │ 257 │ Int32           │
└─────┴───────────────┴─────┴─────────────────┘
```

<div id="reinterpretAsInt64">
  ## reinterpretAsInt64
</div>

도입 버전: v1.1.0

입력 값을 Int64 형식의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리, 이 함수는 원래 값을 보존하려고 하지 않습니다. 대상 형식이 입력 형식을 표현할 수 없으면 출력은 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsInt64(x)
```

**인수**

* `x` — Int64로 재해석할 값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

재해석된 값 `x`를 반환합니다. [`Int64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt32(257) AS x,
    toTypeName(x),
    reinterpretAsInt64(x) AS res,
    toTypeName(res)
```

```response title=Response theme={null}
┌───x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 257 │ Int32         │ 257 │ Int64           │
└─────┴───────────────┴─────┴─────────────────┘
```

<div id="reinterpretAsInt8">
  ## reinterpretAsInt8
</div>

도입 버전: v1.1.0

입력 값을 Int8 유형의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리, 이 함수는 원래 값을 유지하려고 하지 않습니다. 대상 유형으로 입력 유형을 표현할 수 없으면 출력은 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsInt8(x)
```

**인수**

* `x` — Int8로 재해석할 값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

재해석한 값 `x`를 반환합니다. [`Int8`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt8(257) AS x,
    toTypeName(x),
    reinterpretAsInt8(x) AS res,
    toTypeName(res)
```

```response title=Response theme={null}
┌─x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 1 │ UInt8         │   1 │ Int8            │
└───┴───────────────┴─────┴─────────────────┘
```

<div id="reinterpretAsString">
  ## reinterpretAsString
</div>

도입 버전: v1.1.0

입력 값을 문자열로 재해석합니다(little endian order를 가정).
끝에 있는 널 바이트는 무시됩니다. 예를 들어, 이 함수는 UInt32 값 255를 단일 문자로 이루어진 문자열로 반환합니다.

**구문**

```sql theme={null}
reinterpretAsString(x)
```

**인수**

* `x` — 문자열로 재해석할 값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime)

**반환 값**

`x`를 나타내는 바이트가 포함된 String입니다. [`String`](/ko/reference/data-types/string)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    reinterpretAsString(toDateTime('1970-01-01 01:01:05')),
    reinterpretAsString(toDate('1970-03-07'))
```

```response title=Response theme={null}
┌─reinterpretAsString(toDateTime('1970-01-01 01:01:05'))─┬─reinterpretAsString(toDate('1970-03-07'))─┐
│ A                                                      │ A                                         │
└────────────────────────────────────────────────────────┴───────────────────────────────────────────┘
```

<div id="reinterpretAsUInt128">
  ## reinterpretAsUInt128
</div>

도입 버전: v1.1.0

입력 값을 UInt128 유형의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리, 이 함수는 원래 값을 보존하려고 하지 않습니다. 대상 유형이 입력 유형을 표현할 수 없으면 출력은 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsUInt128(x)
```

**인수**

* `x` — UInt128로 재해석할 값. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

재해석된 값 `x`를 반환합니다. [`UInt128`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt64(257) AS x,
    toTypeName(x),
    reinterpretAsUInt128(x) AS res,
    toTypeName(res)
```

```response title=Response theme={null}
┌───x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 257 │ UInt64        │ 257 │ UInt128         │
└─────┴───────────────┴─────┴─────────────────┘
```

<div id="reinterpretAsUInt16">
  ## reinterpretAsUInt16
</div>

도입 버전: v1.1.0

입력 값을 UInt16 유형의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리, 이 함수는 원본 값을 보존하려고 하지 않습니다. 대상 유형이 입력 유형을 표현하지 못하면 결과는 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsUInt16(x)
```

**인수**

* `x` — UInt16으로 재해석할 값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

재해석한 값 `x`를 반환합니다. [`UInt16`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt8(257) AS x,
    toTypeName(x),
    reinterpretAsUInt16(x) AS res,
    toTypeName(res)
```

```response title=Response theme={null}
┌─x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 1 │ UInt8         │   1 │ UInt16          │
└───┴───────────────┴─────┴─────────────────┘
```

<div id="reinterpretAsUInt256">
  ## reinterpretAsUInt256
</div>

도입 버전: v1.1.0

입력 값을 UInt256 유형의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리, 이 함수는 원래 값을 보존하지 않습니다. 대상 유형으로 입력 유형을 표현할 수 없으면 출력은 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsUInt256(x)
```

**인수**

* `x` — `UInt256`으로 재해석할 값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

재해석된 값 `x`를 반환합니다. [`UInt256`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt128(257) AS x,
    toTypeName(x),
    reinterpretAsUInt256(x) AS res,
    toTypeName(res)
```

```response title=Response theme={null}
┌───x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 257 │ UInt128       │ 257 │ UInt256         │
└─────┴───────────────┴─────┴─────────────────┘
```

<div id="reinterpretAsUInt32">
  ## reinterpretAsUInt32
</div>

도입 버전: v1.1.0

입력 값을 UInt32 타입의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리, 이 함수는 원래 값을 보존하려고 하지 않습니다. 대상 타입이 입력 타입을 표현할 수 없으면 출력 결과는 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsUInt32(x)
```

**인수**

* `x` — UInt32로 재해석할 값. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

재해석된 값 `x`를 반환합니다. [`UInt32`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt16(257) AS x,
    toTypeName(x),
    reinterpretAsUInt32(x) AS res,
    toTypeName(res)
```

```response title=Response theme={null}
┌───x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 257 │ UInt16        │ 257 │ UInt32          │
└─────┴───────────────┴─────┴─────────────────┘
```

<div id="reinterpretAsUInt64">
  ## reinterpretAsUInt64
</div>

도입 버전: v1.1.0

입력 값을 UInt64 타입의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리 이 함수는 원래 값을 보존하려고 시도하지 않습니다. 대상 타입으로 입력 타입을 표현할 수 없으면 출력은 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsUInt64(x)
```

**인수**

* `x` — UInt64로 재해석할 값. [`Int*`](/ko/reference/data-types/int-uint) 또는 [`UInt*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

`x`를 재해석한 값을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt32(257) AS x,
    toTypeName(x),
    reinterpretAsUInt64(x) AS res,
    toTypeName(res)
```

```response title=Response theme={null}
┌───x─┬─toTypeName(x)─┬─res─┬─toTypeName(res)─┐
│ 257 │ UInt32        │ 257 │ UInt64          │
└─────┴───────────────┴─────┴─────────────────┘
```

<div id="reinterpretAsUInt8">
  ## reinterpretAsUInt8
</div>

도입 버전: v1.1.0

입력 값을 UInt8 유형의 값으로 재해석합니다.
[`CAST`](#CAST)와 달리, 이 함수는 원래 값을 유지하려고 하지 않습니다. 대상 유형으로 입력 유형을 표현할 수 없으면 출력은 정의되지 않습니다.

**구문**

```sql theme={null}
reinterpretAsUInt8(x)
```

**인수**

* `x` — UInt8로 재해석할 값입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`UUID`](/ko/reference/data-types/uuid) 또는 [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

재해석된 값 `x`를 반환합니다. [`UInt8`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt8(-1) AS val,
    toTypeName(val),
    reinterpretAsUInt8(val) AS res,
    toTypeName(res);
```

```response title=Response theme={null}
┌─val─┬─toTypeName(val)─┬─res─┬─toTypeName(res)─┐
│  -1 │ Int8            │ 255 │ UInt8           │
└─────┴─────────────────┴─────┴─────────────────┘
```

<div id="reinterpretAsUUID">
  ## reinterpretAsUUID
</div>

도입 버전: v1.1.0

16바이트 문자열을 받아 각 8바이트 절반을 리틀 엔디언 바이트 순서로 해석한 UUID를 반환합니다. 문자열 길이가 충분하지 않으면 문자열 끝이 필요한 수의 null byte로 채워진 것처럼 함수가 동작합니다. 문자열이 16바이트보다 길면 끝의 추가 바이트는 무시됩니다.

**구문**

```sql theme={null}
reinterpretAsUUID(fixed_string)
```

**인수**

* `fixed_string` — 빅 엔디언 바이트 문자열입니다. [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

UUID 타입의 값입니다. [`UUID`](/ko/reference/data-types/uuid)

**예시**

**문자열에서 UUID로**

```sql title=Query theme={null}
SELECT reinterpretAsUUID(reverse(unhex('000102030405060708090a0b0c0d0e0f')))
```

```response title=Response theme={null}
┌─reinterpretAsUUID(reverse(unhex('000102030405060708090a0b0c0d0e0f')))─┐
│                                  08090a0b-0c0d-0e0f-0001-020304050607 │
└───────────────────────────────────────────────────────────────────────┘
```

<div id="toBFloat16">
  ## toBFloat16
</div>

도입 버전: v1.1.0

입력값을 BFloat16 유형의 값으로 변환합니다.
오류가 발생하면 예외를 발생시킵니다.

관련 항목:

* [`toBFloat16OrZero`](#toBFloat16OrZero).
* [`toBFloat16OrNull`](#toBFloat16OrNull).

**구문**

```sql theme={null}
toBFloat16(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

16비트 brain-float 값을 반환합니다. [`BFloat16`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
toBFloat16(toFloat32(42.7)),
toBFloat16(toFloat32('42.7')),
toBFloat16('42.7')
FORMAT Vertical;
```

```response title=Response theme={null}
toBFloat16(toFloat32(42.7)): 42.5
toBFloat16(t⋯32('42.7')):    42.5
toBFloat16('42.7'):          42.5
```

<div id="toBFloat16OrNull">
  ## toBFloat16OrNull
</div>

도입 버전: v1.1.0

String 입력값을 BFloat16 유형의 값으로 변환합니다.
문자열이 부동소수점 값을 나타내지 않으면 NULL을 반환합니다.

지원되는 인수:

* 숫자 값의 문자열 표현.

지원되지 않는 인수(`NULL` 반환):

* 2진수 및 16진수 값의 문자열 표현.
* 숫자 값.

<Note>
  이 함수는 문자열 표현에서 변환할 때 정밀도가 일부 손실되어도 오류를 발생시키지 않습니다.
</Note>

관련 항목:

* [`toBFloat16`](#toBFloat16).
* [`toBFloat16OrZero`](#toBFloat16OrZero).

**구문**

```sql theme={null}
toBFloat16OrNull(x)
```

**인수**

* `x` — 숫자를 나타내는 문자열입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

16비트 brain-float 값 또는 `NULL`을 반환합니다. [`BFloat16`](/ko/reference/data-types/float) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toBFloat16OrNull('0x5E'), -- 지원되지 않는 인수
       toBFloat16OrNull('12.3'), -- 일반적인 사용 예
       toBFloat16OrNull('12.3456789') -- 정밀도 손실이 발생해도 별도 알림 없음
```

```response title=Response theme={null}
\N
12.25
12.3125
```

<div id="toBFloat16OrZero">
  ## toBFloat16OrZero
</div>

도입 버전: v1.1.0

String 입력값을 BFloat16 유형의 값으로 변환합니다.
문자열이 부동소수점 값을 나타내지 않으면 함수는 0을 반환합니다.

지원되는 인수:

* 숫자 값의 문자열 표현.

지원되지 않는 인수(`0` 반환):

* binary 및 hexadecimal 값의 문자열 표현.
* 숫자 값.

<Note>
  이 함수는 문자열 표현에서 변환하는 과정에서 정밀도가 소리 없이 손실되는 것을 허용합니다.
</Note>

관련 항목:

* [`toBFloat16`](#toBFloat16).
* [`toBFloat16OrNull`](#toBFloat16OrNull).

**구문**

```sql theme={null}
toBFloat16OrZero(x)
```

**인수**

* `x` — 숫자를 나타내는 `String`입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

16비트 brain-float 값을 반환하며, 그렇지 않으면 `0`을 반환합니다. [`BFloat16`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toBFloat16OrZero('0x5E'), -- 지원되지 않는 인수
       toBFloat16OrZero('12.3'), -- 일반적인 사용
       toBFloat16OrZero('12.3456789') -- 정밀도가 조용히 손실됨
```

```response title=Response theme={null}
0
12.25
12.3125
```

<div id="toBool">
  ## toBool
</div>

도입 버전: v22.2.0

입력값을 Bool 유형으로 변환합니다.

**구문**

```sql theme={null}
toBool(expr)
```

**인수**

* `expr` — 숫자 또는 문자열을 반환하는 표현식입니다. 문자열은 'true' 또는 'false'를 허용하며, 대소문자를 구분하지 않습니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`String`](/ko/reference/data-types/string) 또는 [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

인수의 평가 결과에 따라 `true` 또는 `false`를 반환합니다. [`Bool`](/ko/reference/data-types/boolean)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toBool(toUInt8(1)),
    toBool(toInt8(-1)),
    toBool(toFloat32(1.01)),
    toBool('true'),
    toBool('false'),
    toBool('FALSE')
FORMAT Vertical
```

```response title=Response theme={null}
toBool(toUInt8(1)):      true
toBool(toInt8(-1)):      true
toBool(toFloat32(1.01)): true
toBool('true'):          true
toBool('false'):         false
toBool('FALSE'):         false
```

<div id="toDate">
  ## toDate
</div>

도입 버전: v1.1.0

입력 값을 [`Date`](/ko/reference/data-types/date) 타입으로 변환합니다.
String, FixedString, DateTime 또는 숫자 타입에서 변환할 수 있습니다.

**구문**

```sql theme={null}
toDate(x)
```

**인수**

* `x` — 변환할 입력 값입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)

**반환 값**

변환된 입력 값을 반환합니다. [`Date`](/ko/reference/data-types/date)

**예시**

**String을 Date로 변환하기**

```sql title=Query theme={null}
SELECT toDate('2025-04-15')
```

```response title=Response theme={null}
2025-04-15
```

**DateTime에서 Date로 변환**

```sql title=Query theme={null}
SELECT toDate(toDateTime('2025-04-15 10:30:00'))
```

```response title=Response theme={null}
2025-04-15
```

**정수를 Date로 변환**

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

```response title=Response theme={null}
2025-07-28
```

<div id="toDate32">
  ## toDate32
</div>

도입 버전: v21.9.0

인수를 [Date32](/ko/reference/data-types/date32) 데이터 타입으로 변환합니다.
값이 범위를 벗어나면 `toDate32`는 [Date32](/ko/reference/data-types/date32)에서 지원하는 경곗값을 반환합니다.
인수의 타입이 [`Date`](/ko/reference/data-types/date)인 경우 해당 타입의 경계값을 기준으로 처리됩니다.

**구문**

```sql theme={null}
toDate32(expr)
```

**인수**

* `expr` — 변환할 값입니다. [`String`](/ko/reference/data-types/string) 또는 [`UInt32`](/ko/reference/data-types/int-uint) 또는 [`Date`](/ko/reference/data-types/date)

**반환 값**

달력 날짜를 반환합니다. [`Date32`](/ko/reference/data-types/date32)

**예시**

**범위 내**

```sql title=Query theme={null}
SELECT toDate32('2025-01-01') AS value, toTypeName(value)
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
value:           2025-01-01
toTypeName(value): Date32
```

**범위를 벗어남**

```sql title=Query theme={null}
SELECT toDate32('1899-01-01') AS value, toTypeName(value)
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
value:           1900-01-01
toTypeName(value): Date32
```

<div id="toDate32OrDefault">
  ## toDate32OrDefault
</div>

도입 버전: v21.11.0

인수를 [Date32](/ko/reference/data-types/date32) 데이터 타입으로 변환합니다. 값이 범위를 벗어나면 `toDate32OrDefault`는 [Date32](/ko/reference/data-types/date32)에서 지원하는 하한 경계값을 반환합니다. 인수가 [Date](/ko/reference/data-types/date) 타입이면 해당 타입의 경계값이 적용됩니다. 잘못된 인수를 받으면 기본값을 반환합니다.

**구문**

```sql theme={null}
toDate32OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패한 경우 반환할 기본값입니다. [`Date32`](/ko/reference/data-types/date32)

**반환 값**

성공하면 `Date32` 타입의 값을 반환하고, 실패하면 전달된 기본값을 반환하며, 기본값이 없으면 1900-01-01을 반환합니다. [`Date32`](/ko/reference/data-types/date32)

**예시**

**성공적인 변환**

```sql title=Query theme={null}
SELECT toDate32OrDefault('1930-01-01', toDate32('2020-01-01'))
```

```response title=Response theme={null}
1930-01-01
```

**변환 실패**

```sql title=Query theme={null}
SELECT toDate32OrDefault('xx1930-01-01', toDate32('2020-01-01'))
```

```response title=Response theme={null}
2020-01-01
```

<div id="toDate32OrNull">
  ## toDate32OrNull
</div>

도입 버전: v21.9.0

입력 값을 Date32 유형의 값으로 변환하며, 유효하지 않은 인수가 전달되면 `NULL`을 반환합니다.
[`toDate32`](#toDate32)와 동일하지만, 유효하지 않은 인수가 전달되면 `NULL`을 반환합니다.

**구문**

```sql theme={null}
toDate32OrNull(x)
```

**인수**

* `x` — 날짜를 나타내는 문자열입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 `Date32` 값을 반환하고, 그렇지 않으면 `NULL`을 반환합니다. [`Date32`](/ko/reference/data-types/date32) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDate32OrNull('2025-01-01'), toDate32OrNull('invalid')
```

```response title=Response theme={null}
┌─toDate32OrNull('2025-01-01')─┬─toDate32OrNull('invalid')─┐
│                   2025-01-01 │                      ᴺᵁᴸᴸ │
└──────────────────────────────┴───────────────────────────┘
```

<div id="toDate32OrZero">
  ## toDate32OrZero
</div>

도입 버전: v21.9.0

입력 값을 [Date32](/ko/reference/data-types/date32) 타입의 값으로 변환하며, 유효하지 않은 인수가 전달되면 [Date32](/ko/reference/data-types/date32)의 하한값을 반환합니다.
[toDate32](#toDate32)와 동일하지만, 유효하지 않은 인수가 전달되면 [Date32](/ko/reference/data-types/date32)의 하한값을 반환합니다.

관련 항목:

* [`toDate32`](#toDate32)
* [`toDate32OrNull`](#toDate32OrNull)
* [`toDate32OrDefault`](#toDate32OrDefault)

**구문**

```sql theme={null}
toDate32OrZero(x)
```

**인수**

* `x` — 날짜를 나타내는 문자열입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 Date32 값을 반환하고, 그렇지 않으면 Date32의 하한 값(`1900-01-01`)을 반환합니다. [`Date32`](/ko/reference/data-types/date32)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDate32OrZero('2025-01-01'), toDate32OrZero('')
```

```response title=Response theme={null}
┌─toDate32OrZero('2025-01-01')─┬─toDate32OrZero('')─┐
│                   2025-01-01 │         1900-01-01 │
└──────────────────────────────┴────────────────────┘
```

<div id="toDateOrDefault">
  ## toDateOrDefault
</div>

도입 버전: v21.11.0

[toDate](#toDate)와 같지만, 변환에 실패하면 기본값을 반환합니다. 기본값은 두 번째 인수로 지정한 값이며, 지정하지 않으면 [Date](/ko/reference/data-types/date)의 하한값이 반환됩니다.

**구문**

```sql theme={null}
toDateOrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패하면 반환할 기본값입니다. [`Date`](/ko/reference/data-types/date)

**반환 값**

성공하면 `Date` 타입의 값을 반환하고, 그렇지 않으면 전달된 기본값이 있으면 해당 값을, 없으면 1970-01-01을 반환합니다. [`Date`](/ko/reference/data-types/date)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toDateOrDefault('2022-12-30')
```

```response title=Response theme={null}
2022-12-30
```

**변환 실패**

```sql title=Query theme={null}
SELECT toDateOrDefault('', CAST('2023-01-01', 'Date'))
```

```response title=Response theme={null}
2023-01-01
```

<div id="toDateOrNull">
  ## toDateOrNull
</div>

도입 버전: v1.1.0

입력 값을 `Date` 유형으로 변환하되, 유효하지 않은 인수가 전달되면 `NULL`을 반환합니다.
[`toDate`](#toDate)와 동일하지만, 유효하지 않은 인수가 전달되면 `NULL`을 반환합니다.

**구문**

```sql theme={null}
toDateOrNull(x)
```

**인수**

* `x` — 날짜를 나타내는 문자열입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 `Date` 값을 반환하고, 그렇지 않으면 `NULL`을 반환합니다. [`Date`](/ko/reference/data-types/date) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDateOrNull('2025-12-30'), toDateOrNull('invalid')
```

```response title=Response theme={null}
┌─toDateOrNull('2025-12-30')─┬─toDateOrNull('invalid')─┐
│                 2025-12-30 │                   ᴺᵁᴸᴸ │
└────────────────────────────┴────────────────────────┘
```

<div id="toDateOrZero">
  ## toDateOrZero
</div>

도입 버전: v1.1.0

입력값을 [`Date`](/ko/reference/data-types/date) 타입의 값으로 변환하며, 유효하지 않은 인수가 전달되면 [`Date`](/ko/reference/data-types/date)의 하한값을 반환합니다.
[toDate](#toDate)와 동일하지만, 유효하지 않은 인수가 전달되면 [`Date`](/ko/reference/data-types/date)의 하한값을 반환합니다.

관련 항목:

* [`toDate`](#toDate)
* [`toDateOrNull`](#toDateOrNull)
* [`toDateOrDefault`](#toDateOrDefault)

**구문**

```sql theme={null}
toDateOrZero(x)
```

**인수**

* `x` — 날짜를 나타내는 문자열입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 Date 값을 반환하고, 실패하면 Date의 하한값(`1970-01-01`)을 반환합니다. [`Date`](/ko/reference/data-types/date)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDateOrZero('2025-12-30'), toDateOrZero('')
```

```response title=Response theme={null}
┌─toDateOrZero('2025-12-30')─┬─toDateOrZero('')─┐
│                 2025-12-30 │       1970-01-01 │
└────────────────────────────┴──────────────────┘
```

<div id="toDateTime">
  ## toDateTime
</div>

도입 버전: v1.1.0

입력 값을 [DateTime](/ko/reference/data-types/datetime) 타입으로 변환합니다.

<Note>
  `expr`이 숫자이면 Unix epoch 시작 시점부터 경과한 초 수(Unix timestamp)로 해석됩니다.
  `expr`이 [String](/ko/reference/data-types/string)이면 Unix timestamp로 해석되거나 날짜 또는 날짜/시간의 문자열 표현으로 해석될 수 있습니다.
  따라서 짧은 숫자 문자열 표현(최대 4자리)은 모호성을 피하기 위해 명시적으로 비활성화되어 있습니다. 예를 들어 문자열 `'1999'`는 연도(Date / DateTime의 불완전한 문자열 표현)일 수도 있고 Unix timestamp일 수도 있습니다. 더 긴 숫자 문자열은 허용됩니다.
</Note>

**구문**

```sql theme={null}
toDateTime(expr[, time_zone])
```

**인수**

* `expr` — 값입니다. [`String`](/ko/reference/data-types/string) 또는 [`Int`](/ko/reference/data-types/int-uint) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime)
* `time_zone` — 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

날짜 및 시간 값을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDateTime('2025-01-01 00:00:00'), toDateTime(1735689600, 'UTC')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toDateTime('2025-01-01 00:00:00'): 2025-01-01 00:00:00
toDateTime(1735689600, 'UTC'):     2025-01-01 00:00:00
```

<div id="toDateTime32">
  ## toDateTime32
</div>

도입 버전: v20.9.0

입력값을 `DateTime` 타입으로 변환합니다.
`String`, `FixedString`, `Date`, `Date32`, `DateTime` 또는 숫자 타입(`(U)Int*`, `Float*`, `Decimal`)에서의 변환을 지원합니다.
DateTime32는 `DateTime`보다 더 넓은 범위를 제공하며, `1900-01-01`부터 `2299-12-31`까지의 날짜를 지원합니다.

**구문**

```sql theme={null}
toDateTime32(x[, timezone])
```

**인수**

* `x` — 변환할 입력 값입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring) 또는 [`UInt*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`DateTime64`](/ko/reference/data-types/datetime64)
* `timezone` — 선택 사항입니다. 반환되는 `DateTime` 값에 사용할 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

변환된 입력 값을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**값이 범위 내에 있는 경우**

```sql title=Query theme={null}
SELECT toDateTime64('2025-01-01 00:00:00.000', 3) AS value, toTypeName(value);
```

```response title=Response theme={null}
┌───────────────────value─┬─toTypeName(toDateTime64('20255-01-01 00:00:00.000', 3))─┐
│ 2025-01-01 00:00:00.000 │ DateTime64(3)                                          │
└─────────────────────────┴────────────────────────────────────────────────────────┘
```

**정밀도가 지정된 Decimal로**

```sql title=Query theme={null}
SELECT toDateTime64(1735689600.000, 3) AS value, toTypeName(value);
-- 소수점이 없어도 해당 값은 여전히 초 단위 Unix timestamp로 처리됩니다
SELECT toDateTime64(1546300800000, 3) AS value, toTypeName(value);
```

```response title=Response theme={null}
┌───────────────────value─┬─toTypeName(toDateTime64(1735689600.000, 3))─┐
│ 2025-01-01 00:00:00.000 │ DateTime64(3)                            │
└─────────────────────────┴──────────────────────────────────────────┘
┌───────────────────value─┬─toTypeName(toDateTime64(1546300800000, 3))─┐
│ 2282-12-31 00:00:00.000 │ DateTime64(3)                              │
└─────────────────────────┴────────────────────────────────────────────┘
```

**시간대 지정**

```sql title=Query theme={null}
SELECT toDateTime64('2025-01-01 00:00:00', 3, 'Asia/Istanbul') AS value, toTypeName(value);
```

```response title=Response theme={null}
┌───────────────────value─┬─toTypeName(toDateTime64('2025-01-01 00:00:00', 3, 'Asia/Istanbul'))─┐
│ 2025-01-01 00:00:00.000 │ DateTime64(3, 'Asia/Istanbul')                                      │
└─────────────────────────┴─────────────────────────────────────────────────────────────────────┘
```

<div id="toDateTime64">
  ## toDateTime64
</div>

도입 버전: v20.1.0

입력값을 [`DateTime64`](/ko/reference/data-types/datetime64) 타입의 값으로 변환합니다.

**구문**

```sql theme={null}
toDateTime64(expr, scale[, timezone])
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)
* `scale` — 틱 크기(정밀도)입니다: 10^(-scale)초. [`UInt8`](/ko/reference/data-types/int-uint)
* `timezone` — 선택 사항입니다. 지정된 `DateTime64` 객체의 시간대입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

하위 초 단위 정밀도를 포함하는 날짜 및 시각을 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**예시**

**값이 범위 내에 있는 경우**

```sql title=Query theme={null}
SELECT toDateTime64('2025-01-01 00:00:00.000', 3) AS value, toTypeName(value);
```

```response title=Response theme={null}
┌───────────────────value─┬─toTypeName(toDateTime64('2025-01-01 00:00:00.000', 3))─┐
│ 2025-01-01 00:00:00.000 │ DateTime64(3)                                          │
└─────────────────────────┴────────────────────────────────────────────────────────┘
```

**precision이 지정된 Decimal로**

```sql title=Query theme={null}
SELECT toDateTime64(1546300800.000, 3) AS value, toTypeName(value);
-- 소수점이 없어도 값은 여전히 초 단위 Unix timestamp로 처리됩니다
SELECT toDateTime64(1546300800000, 3) AS value, toTypeName(value);
```

```response title=Response theme={null}
┌───────────────────value─┬─toTypeName(toDateTime64(1546300800000, 3))─┐
│ 2282-12-31 00:00:00.000 │ DateTime64(3)                              │
└─────────────────────────┴────────────────────────────────────────────┘
```

**시간대 지정**

```sql title=Query theme={null}
SELECT toDateTime64('2025-01-01 00:00:00', 3, 'Asia/Istanbul') AS value, toTypeName(value);
```

```response title=Response theme={null}
┌───────────────────value─┬─toTypeName(toDateTime64('2025-01-01 00:00:00', 3, 'Asia/Istanbul'))─┐
│ 2025-01-01 00:00:00.000 │ DateTime64(3, 'Asia/Istanbul')                                      │
└─────────────────────────┴─────────────────────────────────────────────────────────────────────┘
```

<div id="toDateTime64OrDefault">
  ## toDateTime64OrDefault
</div>

도입 버전: v21.11.0

[toDateTime64](#toDateTime64)와 마찬가지로, 이 함수는 입력 값을 [DateTime64](/ko/reference/data-types/datetime64) 타입의 값으로 변환하지만,
유효하지 않은 인수가 전달되면 [DateTime64](/ko/reference/data-types/datetime64)의 기본값
또는 지정된 기본값을 반환합니다.

**구문**

```sql theme={null}
toDateTime64OrDefault(expr, scale[, timezone, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `scale` — 틱 크기(정밀도)입니다: 10^-정밀도초. [`UInt8`](/ko/reference/data-types/int-uint)
* `timezone` — 선택 사항입니다. 시간대입니다. [`String`](/ko/reference/data-types/string)
* `default` — 선택 사항입니다. 파싱에 실패할 경우 반환할 기본값입니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**반환 값**

성공하면 DateTime64 타입의 값을 반환합니다. 실패하면 전달된 경우 기본값을 반환하고, 전달되지 않은 경우 1970-01-01 00:00:00.000을 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toDateTime64OrDefault('1976-10-18 00:00:00.30', 3)
```

```response title=Response theme={null}
1976-10-18 00:00:00.300
```

**변환 실패**

```sql title=Query theme={null}
SELECT toDateTime64OrDefault('1976-10-18 00:00:00 30', 3, 'UTC', toDateTime64('2001-01-01 00:00:00.00',3))
```

```response title=Response theme={null}
2000-12-31 23:00:00.000
```

<div id="toDateTime64OrNull">
  ## toDateTime64OrNull
</div>

도입 버전: v20.1.0

입력값을 `DateTime64` 유형의 값으로 변환하며, 유효하지 않은 인수가 전달되면 `NULL`을 반환합니다.
`toDateTime64`와 동일하지만, 유효하지 않은 인수가 전달되면 `NULL`을 반환합니다.

**구문**

```sql theme={null}
toDateTime64OrNull(x)
```

**인수**

* `x` — 시간과 초 미만 정밀도를 포함한 날짜를 문자열로 표현한 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 DateTime64 값을 반환하고, 그렇지 않으면 `NULL`을 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDateTime64OrNull('2025-12-30 13:44:17.123'), toDateTime64OrNull('invalid')
```

```response title=Response theme={null}
┌─toDateTime64OrNull('2025-12-30 13:44:17.123')─┬─toDateTime64OrNull('invalid')─┐
│                         2025-12-30 13:44:17.123 │                          ᴺᵁᴸᴸ │
└─────────────────────────────────────────────────┴───────────────────────────────┘
```

<div id="toDateTime64OrZero">
  ## toDateTime64OrZero
</div>

도입 버전: v20.1.0

입력 값을 [DateTime64](/ko/reference/data-types/datetime64) 타입의 값으로 변환하지만, 유효하지 않은 인수가 전달되면 [DateTime64](/ko/reference/data-types/datetime64)의 하한값을 반환합니다.
[toDateTime64](#toDateTime64)와 동일하지만, 유효하지 않은 인수가 전달되면 [DateTime64](/ko/reference/data-types/datetime64)의 하한값을 반환합니다.

관련 항목:

* [toDateTime64](#toDateTime64).
* [toDateTime64OrNull](#toDateTime64OrNull).
* [toDateTime64OrDefault](#toDateTime64OrDefault).

**구문**

```sql theme={null}
toDateTime64OrZero(x)
```

**인수**

* `x` — 날짜, 시간, 초 미만 정밀도를 포함한 문자열 표현입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 DateTime64 값을 반환하고, 그렇지 않으면 DateTime64의 하한값(`1970-01-01 00:00:00.000`)을 반환합니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDateTime64OrZero('2025-12-30 13:44:17.123'), toDateTime64OrZero('invalid')
```

```response title=Response theme={null}
┌─toDateTime64OrZero('2025-12-30 13:44:17.123')─┬─toDateTime64OrZero('invalid')─┐
│                         2025-12-30 13:44:17.123 │             1970-01-01 00:00:00.000 │
└─────────────────────────────────────────────────┴─────────────────────────────────────┘
```

<div id="toDateTimeOrDefault">
  ## toDateTimeOrDefault
</div>

도입 버전: v21.11.0

[toDateTime](#toDateTime)와 비슷하지만, 변환에 실패하면 기본값을 반환합니다. 기본값은 세 번째 인수(지정된 경우)이며, 지정되지 않으면 [DateTime](/ko/reference/data-types/datetime)의 하한값을 반환합니다.

**구문**

```sql theme={null}
toDateTimeOrDefault(expr[, timezone, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `timezone` — 선택 사항입니다. 시간대입니다. [`String`](/ko/reference/data-types/string)
* `default` — 선택 사항입니다. 파싱에 실패할 경우 반환할 기본값입니다. [`DateTime`](/ko/reference/data-types/datetime)

**반환 값**

성공하면 `DateTime` 타입의 값을 반환합니다. 실패하면 `default`가 전달된 경우 해당 기본값을 반환하고, 그렇지 않으면 `1970-01-01 00:00:00`을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toDateTimeOrDefault('2022-12-30 13:44:17')
```

```response title=Response theme={null}
2022-12-30 13:44:17
```

**변환 실패**

```sql title=Query theme={null}
SELECT toDateTimeOrDefault('', 'UTC', CAST('2023-01-01', 'DateTime(\'UTC\')'))
```

```response title=Response theme={null}
2023-01-01 00:00:00
```

<div id="toDateTimeOrNull">
  ## toDateTimeOrNull
</div>

도입 버전: v1.1.0

입력값을 `DateTime` 타입의 값으로 변환하되, 잘못된 인수가 전달되면 `NULL`을 반환합니다.
[`toDateTime`](#toDateTime)과 동일하지만, 잘못된 인수가 전달되면 `NULL`을 반환합니다.

**구문**

```sql theme={null}
toDateTimeOrNull(x)
```

**인수**

* `x` — 시간이 포함된 날짜를 문자열로 표현한 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 `DateTime` 값을 반환하고, 그렇지 않으면 `NULL`을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDateTimeOrNull('2025-12-30 13:44:17'), toDateTimeOrNull('invalid')
```

```response title=Response theme={null}
┌─toDateTimeOrNull('2025-12-30 13:44:17')─┬─toDateTimeOrNull('invalid')─┐
│                     2025-12-30 13:44:17 │                        ᴺᵁᴸᴸ │
└─────────────────────────────────────────┴─────────────────────────────┘
```

<div id="toDateTimeOrZero">
  ## toDateTimeOrZero
</div>

도입 버전: v1.1.0

입력 값을 [DateTime](/ko/reference/data-types/datetime) 타입의 값으로 변환하지만, 잘못된 인수를 받으면 [DateTime](/ko/reference/data-types/datetime)의 하한값을 반환합니다.
[toDateTime](#toDateTime)과 동일하지만, 잘못된 인수를 받으면 [DateTime](/ko/reference/data-types/datetime)의 하한값을 반환합니다.

**구문**

```sql theme={null}
toDateTimeOrZero(x)
```

**인수**

* `x` — 날짜와 시간을 나타내는 문자열입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 DateTime 값을 반환하고, 그렇지 않으면 DateTime의 하한값(`1970-01-01 00:00:00`)을 반환합니다. [`DateTime`](/ko/reference/data-types/datetime)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDateTimeOrZero('2025-12-30 13:44:17'), toDateTimeOrZero('invalid')
```

```response title=Response theme={null}
┌─toDateTimeOrZero('2025-12-30 13:44:17')─┬─toDateTimeOrZero('invalid')─┐
│                     2025-12-30 13:44:17 │         1970-01-01 00:00:00 │
└─────────────────────────────────────────┴─────────────────────────────┘
```

<div id="toDecimal128">
  ## toDecimal128
</div>

Introduced in: v18.12.0

입력값을 스케일이 `S`인 [`Decimal(38, S)`](/ko/reference/data-types/decimal) 타입의 값으로 변환합니다.
오류가 발생하면 예외를 발생시킵니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 형식의 값
* Float\* 타입의 값 또는 문자열 형식의 값

지원되지 않는 인수:

* Float\* 값 `NaN` 및 `Inf` 또는 이를 문자열로 표현한 값(대소문자 구분 없음)
* 이진수 및 16진수 값을 문자열로 표현한 값. 예: `SELECT toDecimal128('0xc0fe', 1);`

<Note>
  `expr`의 값이 `Decimal128`의 범위 `(-1*10^(38 - S), 1*10^(38 - S))`를 초과하면 오버플로우가 발생할 수 있습니다.
  소수 부분의 초과 자릿수는 버려지며(반올림되지 않음),
  정수 부분의 초과 자릿수는 예외를 발생시킵니다.
</Note>

<Warning>
  변환 시 추가 자릿수는 잘려 나가며, 연산이 부동소수점 명령으로 수행되므로 Float32/Float64 입력을 사용할 때 예상과 다르게 동작할 수 있습니다.
  예를 들어 `toDecimal128(1.15, 2)`는 `1.14`와 같습니다. 부동소수점에서는 1.15 \* 100이 114.99이기 때문입니다.
  연산에 내부 정수 타입이 사용되도록 String 입력을 사용할 수 있습니다: `toDecimal128('1.15', 2) = 1.15`
</Warning>

**구문**

```sql theme={null}
toDecimal128(expr, S)
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)
* `S` — 숫자의 소수부에 허용되는 자릿수를 지정하는 0\~38 범위의 매개변수입니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

`Decimal(38, S)` 유형의 값을 반환합니다. [`Decimal128(S)`](/ko/reference/data-types/decimal)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toDecimal128(99, 1) AS a, toTypeName(a) AS type_a,
    toDecimal128(99.67, 2) AS b, toTypeName(b) AS type_b,
    toDecimal128('99.67', 3) AS c, toTypeName(c) AS type_c
FORMAT Vertical
```

```response title=Response theme={null}
행 1:
──────
a:      99
type_a: Decimal(38, 1)
b:      99.67
type_b: Decimal(38, 2)
c:      99.67
type_c: Decimal(38, 3)
```

<div id="toDecimal128OrDefault">
  ## toDecimal128OrDefault
</div>

도입 버전: v21.11.0

[`toDecimal128`](#toDecimal128)와 마찬가지로, 이 함수는 입력 값을 [Decimal(38, S)](/ko/reference/data-types/decimal) 타입의 값으로 변환하지만, 오류가 발생할 경우 기본값을 반환합니다.

**구문**

```sql theme={null}
toDecimal128OrDefault(expr, S[, default])
```

**인수**

* `expr` — 숫자의 문자열 표현입니다. [`String`](/ko/reference/data-types/string)
* `S` — 숫자의 소수부에 허용되는 자릿수를 지정하는 0\~38 범위의 스케일 매개변수입니다. [`UInt8`](/ko/reference/data-types/int-uint)
* `default` — 선택 사항입니다. Decimal128(S) 타입으로 파싱하지 못한 경우 반환할 기본값입니다. [`Decimal128(S)`](/ko/reference/data-types/decimal)

**반환 값**

성공하면 Decimal(38, S) 타입의 값을 반환하고, 실패하면 `default`가 전달된 경우 해당 기본값을, 그렇지 않으면 0을 반환합니다. [`Decimal128(S)`](/ko/reference/data-types/decimal)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toDecimal128OrDefault(toString(1/42), 18)
```

```response title=Response theme={null}
0.023809523809523808
```

**변환 실패**

```sql title=Query theme={null}
SELECT toDecimal128OrDefault('Inf', 0, CAST('-1', 'Decimal128(0)'))
```

```response title=Response theme={null}
-1
```

<div id="toDecimal128OrNull">
  ## toDecimal128OrNull
</div>

도입 버전: v20.1.0

입력 값을 [`Decimal(38, S)`](/ko/reference/data-types/decimal) 타입의 값으로 변환하며, 오류가 발생하면 `NULL`을 반환합니다.
[`toDecimal128`](#toDecimal128)과 유사하지만, 변환 오류 시 예외를 발생시키는 대신 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값 또는 문자열 표현.

지원되지 않는 인수 (`NULL` 반환):

* Float\* 값 `NaN` 및 `Inf` 또는 그 문자열 표현(대소문자 구분 없음).
* 2진수 및 16진수 값의 문자열 표현.
* `Decimal128`의 범위 `(-1*10^(38 - S), 1*10^(38 - S))`를 초과하는 값.

관련 항목:

* [`toDecimal128`](#toDecimal128).
* [`toDecimal128OrZero`](#toDecimal128OrZero).
* [`toDecimal128OrDefault`](#toDecimal128OrDefault).

**구문**

```sql theme={null}
toDecimal128OrNull(expr, S)
```

**인수**

* `expr` — 숫자 또는 숫자를 나타내는 문자열을 반환하는 표현식. [`표현식`](/ko/reference/data-types/special-data-types/expression)
* `S` — 숫자의 소수부에 허용되는 자릿수를 지정하는 0\~38 범위의 스케일 매개변수입니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 Decimal(38, S) 값을 반환하고, 그렇지 않으면 `NULL`을 반환합니다. [`Decimal128(S)`](/ko/reference/data-types/decimal) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDecimal128OrNull('42.7', 2), toDecimal128OrNull('invalid', 2)
```

```response title=Response theme={null}
┌─toDecimal128OrNull('42.7', 2)─┬─toDecimal128OrNull('invalid', 2)─┐
│                         42.70 │                             ᴺᵁᴸᴸ │
└───────────────────────────────┴──────────────────────────────────┘
```

<div id="toDecimal128OrZero">
  ## toDecimal128OrZero
</div>

도입 버전: v20.1.0

입력값을 [Decimal(38, S)](/ko/reference/data-types/decimal) 타입의 값으로 변환하며, 오류가 발생하면 `0`을 반환합니다.
[`toDecimal128`](#toDecimal128)과 비슷하지만, 변환 오류 시 예외를 발생시키는 대신 `0`을 반환합니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값 또는 문자열 표현.

지원되지 않는 인수(`0` 반환):

* Float\* 값 `NaN` 및 `Inf`의 값 또는 문자열 표현(대소문자 구분 없음).
* binary 및 hexadecimal 값의 문자열 표현.

<Note>
  입력값이 `Decimal128`의 범위 `(-1*10^(38 - S), 1*10^(38 - S))`를 벗어나면 함수는 `0`을 반환합니다.
</Note>

**구문**

```sql theme={null}
toDecimal128OrZero(expr, S)
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`Expression`](/ko/reference/data-types/special-data-types/expression)
* `S` — 숫자 소수부의 자릿수를 지정하는 0\~38 범위의 스케일 매개변수입니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 Decimal(38, S) 값을 반환하며, 그렇지 않으면 `0`을 반환합니다. [`Decimal128(S)`](/ko/reference/data-types/decimal)

**예시**

**기본 사용법**

```sql title=Query theme={null}
SELECT toDecimal128OrZero('42.7', 2), toDecimal128OrZero('invalid', 2)
```

```response title=Response theme={null}
┌─toDecimal128OrZero('42.7', 2)─┬─toDecimal128OrZero('invalid', 2)─┐
│                         42.70 │                             0.00 │
└───────────────────────────────┴──────────────────────────────────┘
```

<div id="toDecimal256">
  ## toDecimal256
</div>

Introduced in: v20.8.0

입력 값을 스케일이 `S`인 [`Decimal(76, S)`](/ko/reference/data-types/decimal) 타입의 값으로 변환합니다. 오류가 발생하면 예외를 발생시킵니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값 또는 문자열 표현.

지원되지 않는 인수:

* Float\* 값 `NaN` 및 `Inf`의 값 또는 문자열 표현(대소문자 구분 없음).
* binary 및 hexadecimal 값의 문자열 표현. 예: `SELECT toDecimal256('0xc0fe', 1);`.

<Note>
  `expr`의 값이 `Decimal256`의 범위 `(-1*10^(76 - S), 1*10^(76 - S))`를 초과하면 오버플로우가 발생할 수 있습니다.
  소수 부분의 초과 자릿수는 버려지며 반올림되지 않습니다.
  정수 부분의 초과 자릿수는 예외를 발생시킵니다.
</Note>

<Warning>
  변환 시 추가 자릿수는 버려지며, 연산이 부동소수점 명령으로 수행되므로 Float32/Float64 입력을 사용할 때 예상치 못한 방식으로 동작할 수 있습니다.
  예를 들어 `toDecimal256(1.15, 2)`는 `1.14`와 같습니다. 이는 부동소수점에서 1.15 \* 100이 114.99이기 때문입니다.
  연산에 내부 정수 타입이 사용되도록 하려면 String 입력을 사용할 수 있습니다: `toDecimal256('1.15', 2) = 1.15`
</Warning>

**구문**

```sql theme={null}
toDecimal256(expr, S)
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)
* `S` — 숫자의 소수부가 가질 수 있는 자릿수를 지정하는 0\~76 범위의 스케일 매개변수입니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

`Decimal(76, S)` 타입의 값을 반환합니다. [`Decimal256(S)`](/ko/reference/data-types/decimal)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toDecimal256(99, 1) AS a, toTypeName(a) AS type_a,
    toDecimal256(99.67, 2) AS b, toTypeName(b) AS type_b,
    toDecimal256('99.67', 3) AS c, toTypeName(c) AS type_c
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
a:      99
type_a: Decimal(76, 1)
b:      99.67
type_b: Decimal(76, 2)
c:      99.67
type_c: Decimal(76, 3)
```

<div id="toDecimal256OrDefault">
  ## toDecimal256OrDefault
</div>

지원 버전: v21.11.0

[`toDecimal256`](#toDecimal256)와 마찬가지로 이 함수는 입력 값을 [Decimal(76, S)](/ko/reference/data-types/decimal) 타입 값으로 변환하며, 오류가 발생하면 기본값을 반환합니다.

**구문**

```sql theme={null}
toDecimal256OrDefault(expr, S[, default])
```

**인수**

* `expr` — 숫자의 문자열 표현입니다. [`String`](/ko/reference/data-types/string)
* `S` — 0에서 76 사이의 스케일 매개변수로, 숫자 소수 부분의 자릿수를 지정합니다. [`UInt8`](/ko/reference/data-types/int-uint)
* `default` — 선택 사항입니다. Decimal256(S) 타입으로 파싱하지 못한 경우 반환할 기본값입니다. [`Decimal256(S)`](/ko/reference/data-types/decimal)

**반환 값**

성공하면 Decimal(76, S) 타입의 값을 반환하고, 그렇지 않으면 `default`가 전달된 경우 해당 값을, 전달되지 않은 경우 0을 반환합니다. [`Decimal256(S)`](/ko/reference/data-types/decimal)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toDecimal256OrDefault(toString(1/42), 76)
```

```response title=Response theme={null}
0.023809523809523808
```

**변환 실패**

```sql title=Query theme={null}
SELECT toDecimal256OrDefault('Inf', 0, CAST('-1', 'Decimal256(0)'))
```

```response title=Response theme={null}
-1
```

<div id="toDecimal256OrNull">
  ## toDecimal256OrNull
</div>

도입 버전: v20.8.0

입력 값을 [`Decimal(76, S)`](/ko/reference/data-types/decimal) 타입의 값으로 변환하며, 오류가 발생하면 `NULL`을 반환합니다.
[`toDecimal256`](#toDecimal256)와 유사하지만, 변환 오류 발생 시 예외를 발생시키는 대신 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값 또는 문자열 표현.

지원되지 않는 인수 (`NULL` 반환):

* Float\* 값 `NaN` 및 `Inf` 또는 이들의 문자열 표현(대소문자 구분 없음).
* binary 및 hexadecimal 값의 문자열 표현.
* `Decimal256`의 범위를 초과하는 값: `(-1 * 10^(76 - S), 1 * 10^(76 - S))`.

관련 항목:

* [`toDecimal256`](#toDecimal256).
* [`toDecimal256OrZero`](#toDecimal256OrZero).
* [`toDecimal256OrDefault`](#toDecimal256OrDefault).

**구문**

```sql theme={null}
toDecimal256OrNull(expr, S)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)
* `S` — 숫자 소수부에 허용되는 자릿수를 지정하는 0\~76 범위의 스케일 매개변수입니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 Decimal(76, S) 값을 반환하며, 그렇지 않으면 `NULL`을 반환합니다. [`Decimal256(S)`](/ko/reference/data-types/decimal) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDecimal256OrNull('42.7', 2), toDecimal256OrNull('invalid', 2)
```

```response title=Response theme={null}
┌─toDecimal256OrNull('42.7', 2)─┬─toDecimal256OrNull('invalid', 2)─┐
│                         42.70 │                             ᴺᵁᴸᴸ │
└───────────────────────────────┴──────────────────────────────────┘
```

<div id="toDecimal256OrZero">
  ## toDecimal256OrZero
</div>

도입 버전: v20.8.0

입력 값을 [Decimal(76, S)](/ko/reference/data-types/decimal) 타입의 값으로 변환하되, 오류가 발생하면 `0`을 반환합니다.
[`toDecimal256`](#toDecimal256)와 동일하지만, 변환 오류 발생 시 예외를 발생시키는 대신 `0`을 반환합니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값 또는 문자열 표현.

지원되지 않는 인수(`0` 반환):

* Float\* 값 `NaN` 및 `Inf` 또는 그 문자열 표현(대소문자 구분 없음).
* binary 및 hexadecimal 값의 문자열 표현.

<Note>
  입력 값이 `Decimal256`의 범위 `(-1*10^(76 - S), 1*10^(76 - S))`를 벗어나면 함수는 `0`을 반환합니다.
</Note>

관련 항목:

* [`toDecimal256`](#toDecimal256).
* [`toDecimal256OrNull`](#toDecimal256OrNull).
* [`toDecimal256OrDefault`](#toDecimal256OrDefault).

**구문**

```sql theme={null}
toDecimal256OrZero(expr, S)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식. [`표현식`](/ko/reference/data-types/special-data-types/expression)
* `S` — 0부터 76 사이의 스케일 매개변수로, 숫자 소수부에 허용되는 자릿수를 지정합니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

성공 시 Decimal(76, S) 값을 반환하고, 그렇지 않으면 `0`을 반환합니다. [`Decimal256(S)`](/ko/reference/data-types/decimal)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDecimal256OrZero('42.7', 2), toDecimal256OrZero('invalid', 2)
```

```response title=Response theme={null}
┌─toDecimal256OrZero('42.7', 2)─┬─toDecimal256OrZero('invalid', 2)─┐
│                         42.70 │                             0.00 │
└───────────────────────────────┴──────────────────────────────────┘
```

<div id="toDecimal32">
  ## toDecimal32
</div>

도입 버전: v18.12.0

입력 값을 스케일이 `S`인 [`Decimal(9, S)`](/ko/reference/data-types/decimal) 타입의 값으로 변환합니다. 오류가 발생하면 예외가 발생합니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값 또는 문자열 표현.

지원되지 않는 인수:

* Float\* 값 `NaN` 및 `Inf`의 값 또는 문자열 표현(대소문자 구분 없음).
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toDecimal32('0xc0fe', 1);`.

<Note>
  `expr`의 값이 `Decimal32`의 범위 `(-1*10^(9 - S), 1*10^(9 - S))`를 초과하면 오버플로우가 발생할 수 있습니다.
  소수 부분의 초과 자릿수는 버려지며(반올림되지 않음),
  정수 부분의 초과 자릿수는 예외를 발생시킵니다.
</Note>

<Warning>
  변환 시 추가 자릿수는 제거되며, 연산이 부동소수점 명령으로 수행되므로 Float32/Float64 입력을 처리할 때 예상과 다르게 동작할 수 있습니다.
  예를 들어 `toDecimal32(1.15, 2)`는 `1.14`와 같습니다. 부동소수점에서 1.15 \* 100은 114.99이기 때문입니다.
  기본 정수 타입을 사용해 연산하도록 String 입력을 사용할 수 있습니다: `toDecimal32('1.15', 2) = 1.15`
</Warning>

**구문**

```sql theme={null}
toDecimal32(expr, S)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식. [`표현식`](/ko/reference/data-types/special-data-types/expression)
* `S` — 0에서 9 사이의 스케일 매개변수로, 숫자의 소수부에 허용되는 자릿수를 지정합니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

`Decimal(9, S)` 타입의 값을 반환합니다. [`Decimal32(S)`](/ko/reference/data-types/decimal)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toDecimal32(2, 1) AS a, toTypeName(a) AS type_a,
    toDecimal32(4.2, 2) AS b, toTypeName(b) AS type_b,
    toDecimal32('4.2', 3) AS c, toTypeName(c) AS type_c
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
a:      2
type_a: Decimal(9, 1)
b:      4.2
type_b: Decimal(9, 2)
c:      4.2
type_c: Decimal(9, 3)
```

<div id="toDecimal32OrDefault">
  ## toDecimal32OrDefault
</div>

도입 버전: v21.11.0

[`toDecimal32`](#toDecimal32)와 마찬가지로, 이 함수는 입력 값을 [Decimal(9, S)](/ko/reference/data-types/decimal) 타입의 값으로 변환하며, 오류가 발생하면 기본값을 반환합니다.

**구문**

```sql theme={null}
toDecimal32OrDefault(expr, S[, default])
```

**인수**

* `expr` — 숫자의 문자열 표현입니다. [`String`](/ko/reference/data-types/string)
* `S` — 0에서 9 사이의 스케일 매개변수로, 숫자의 소수부에 포함될 수 있는 자릿수를 지정합니다. [`UInt8`](/ko/reference/data-types/int-uint)
* `default` — 선택 사항입니다. Decimal32(S) 타입으로 파싱하지 못한 경우 반환할 기본값입니다. [`Decimal32(S)`](/ko/reference/data-types/decimal)

**반환 값**

성공하면 Decimal(9, S) 타입의 값을 반환하고, 그렇지 않으면 `default`가 전달된 경우 해당 기본값을, 전달되지 않은 경우 0을 반환합니다. [`Decimal32(S)`](/ko/reference/data-types/decimal)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toDecimal32OrDefault(toString(0.0001), 5)
```

```response title=Response theme={null}
0.0001
```

**변환 실패**

```sql title=Query theme={null}
SELECT toDecimal32OrDefault('Inf', 0, CAST('-1', 'Decimal32(0)'))
```

```response title=Response theme={null}
-1
```

<div id="toDecimal32OrNull">
  ## toDecimal32OrNull
</div>

도입 버전: v20.1.0

입력값을 [`Decimal(9, S)`](/ko/reference/data-types/decimal) 타입의 값으로 변환하며, 오류가 발생하면 `NULL`을 반환합니다.
[`toDecimal32`](#toDecimal32)와 유사하지만, 변환 오류 시 예외를 발생시키는 대신 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값 또는 문자열 표현.

지원되지 않는 인수 (`NULL` 반환):

* Float\* 값 `NaN` 및 `Inf`의 값 또는 문자열 표현(대소문자 구분 없음).
* binary 및 hexadecimal 값의 문자열 표현.
* `Decimal32`의 범위를 벗어나는 값: `(-1*10^(9 - S), 1*10^(9 - S))`.

관련 항목:

* [`toDecimal32`](#toDecimal32).
* [`toDecimal32OrZero`](#toDecimal32OrZero).
* [`toDecimal32OrDefault`](#toDecimal32OrDefault).

**구문**

```sql theme={null}
toDecimal32OrNull(expr, S)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)
* `S` — 숫자의 소수부에 허용되는 자릿수를 지정하는 0\~9 범위의 스케일 매개변수입니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 Decimal(9, S) 값을 반환하고, 그렇지 않으면 `NULL`을 반환합니다. [`Decimal32(S)`](/ko/reference/data-types/decimal) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDecimal32OrNull('42.7', 2), toDecimal32OrNull('invalid', 2)
```

```response title=Response theme={null}
┌─toDecimal32OrNull('42.7', 2)─┬─toDecimal32OrNull('invalid', 2)─┐
│                        42.70 │                            ᴺᵁᴸᴸ │
└──────────────────────────────┴─────────────────────────────────┘
```

<div id="toDecimal32OrZero">
  ## toDecimal32OrZero
</div>

도입 버전: v20.1.0

입력 값을 [Decimal(9, S)](/ko/reference/data-types/decimal) 타입의 값으로 변환하며, 오류가 발생하면 `0`을 반환합니다.
[`toDecimal32`](#toDecimal32)와 유사하지만, 변환 오류 시 예외를 발생시키는 대신 `0`을 반환합니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현
* Float\* 타입의 값 또는 문자열 표현

지원되지 않는 인수(`0` 반환):

* Float\* 값 `NaN` 및 `Inf`의 값 또는 문자열 표현(case-insensitive)
* binary 및 hexadecimal 값의 문자열 표현

<Note>
  입력 값이 `Decimal32`의 범위 `(-1*10^(9 - S), 1*10^(9 - S))`를 벗어나면 함수는 `0`을 반환합니다.
</Note>

**구문**

```sql theme={null}
toDecimal32OrZero(expr, S)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 나타낸 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)
* `S` — 숫자의 소수 부분에 허용되는 자릿수를 지정하는 0에서 9 사이의 스케일 매개변수입니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 Decimal(9, S) 값을 반환하고, 그렇지 않으면 `0`을 반환합니다. [`Decimal32(S)`](/ko/reference/data-types/decimal)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDecimal32OrZero('42.7', 2), toDecimal32OrZero('invalid', 2)
```

```response title=Response theme={null}
┌─toDecimal32OrZero('42.7', 2)─┬─toDecimal32OrZero('invalid', 2)─┐
│                        42.70 │                            0.00 │
└──────────────────────────────┴─────────────────────────────────┘
```

<div id="toDecimal64">
  ## toDecimal64
</div>

도입 버전: v18.12.0

입력 값을 스케일이 `S`인 [`Decimal(18, S)`](/ko/reference/data-types/decimal) 타입의 값으로 변환합니다.
오류가 발생하면 예외를 발생시킵니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값 또는 문자열 표현.

지원되지 않는 인수:

* Float\* 값 `NaN` 및 `Inf`의 값 또는 문자열 표현(대소문자 구분 없음).
* binary 및 16진수 값의 문자열 표현. 예: `SELECT toDecimal64('0xc0fe', 1);`.

<Note>
  `expr`의 값이 `Decimal64`의 범위 `(-1*10^(18 - S), 1*10^(18 - S))`를 초과하면 오버플로우가 발생할 수 있습니다.
  소수부의 초과 자릿수는 버려지며(반올림되지 않음),
  정수부의 초과 자릿수는 예외를 발생시킵니다.
</Note>

<Warning>
  변환 시 초과 자릿수는 삭제되며, 연산이 부동소수점 명령으로 수행되므로 Float32/Float64 입력을 처리할 때 예상과 다르게 동작할 수 있습니다.
  예를 들어 `toDecimal64(1.15, 2)`는 `1.14`와 같습니다. 부동소수점에서 1.15 \* 100은 114.99가 되기 때문입니다.
  연산이 내부 정수 타입을 사용하도록 하려면 String 입력을 사용할 수 있습니다: `toDecimal64('1.15', 2) = 1.15`
</Warning>

**구문**

```sql theme={null}
toDecimal64(expr, S)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)
* `S` — 숫자의 소수부 자릿수를 지정하는 0\~18 범위의 스케일 매개변수입니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

Decimal 값을 반환합니다. [`Decimal(18, S)`](/ko/reference/data-types/decimal)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toDecimal64(2, 1) AS a, toTypeName(a) AS type_a,
    toDecimal64(4.2, 2) AS b, toTypeName(b) AS type_b,
    toDecimal64('4.2', 3) AS c, toTypeName(c) AS type_c
FORMAT Vertical
```

```response title=Response theme={null}
행 1:
──────
a:      2.0
type_a: Decimal(18, 1)
b:      4.20
type_b: Decimal(18, 2)
c:      4.200
type_c: Decimal(18, 3)
```

<div id="toDecimal64OrDefault">
  ## toDecimal64OrDefault
</div>

도입 버전: v21.11.0

이 함수는 [`toDecimal64`](#toDecimal64)와 마찬가지로 입력 값을 [Decimal(18, S)](/ko/reference/data-types/decimal) 타입의 값으로 변환하지만, 오류가 발생할 경우 기본값을 반환합니다.

**구문**

```sql theme={null}
toDecimal64OrDefault(expr, S[, default])
```

**인수**

* `expr` — 숫자를 나타내는 String 형식의 값입니다. [`String`](/ko/reference/data-types/string)
* `S` — 숫자의 소수부에 허용되는 자릿수를 지정하는 0\~18 범위의 스케일 매개변수입니다. [`UInt8`](/ko/reference/data-types/int-uint)
* `default` — 선택 사항입니다. Decimal64(S) 타입으로 파싱하지 못한 경우 반환할 기본값입니다. [`Decimal64(S)`](/ko/reference/data-types/decimal)

**반환 값**

성공하면 Decimal(18, S) 타입의 값을 반환하며, 실패하면 `default`가 전달된 경우 해당 값을, 그렇지 않으면 0을 반환합니다. [`Decimal64(S)`](/ko/reference/data-types/decimal)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toDecimal64OrDefault(toString(0.0001), 18)
```

```response title=Response theme={null}
0.0001
```

**변환 실패**

```sql title=Query theme={null}
SELECT toDecimal64OrDefault('Inf', 0, CAST('-1', 'Decimal64(0)'))
```

```response title=Response theme={null}
-1
```

<div id="toDecimal64OrNull">
  ## toDecimal64OrNull
</div>

도입 버전: v20.1.0

입력 값을 [Decimal(18, S)](/ko/reference/data-types/decimal) 타입의 값으로 변환하지만, 오류가 발생하면 `NULL`을 반환합니다.
[`toDecimal64`](#toDecimal64)와 비슷하지만, 변환 오류가 발생할 때 예외를 발생시키는 대신 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값 또는 문자열 표현.

지원되지 않는 인수(`NULL` 반환):

* `NaN` 및 `Inf`인 Float\* 값 또는 그 문자열 표현(대소문자 구분 없음).
* 2진수 및 16진수 값의 문자열 표현.
* `Decimal64`의 범위 `(-1*10^(18 - S), 1*10^(18 - S))`를 초과하는 값.

관련 항목:

* [`toDecimal64`](#toDecimal64).
* [`toDecimal64OrZero`](#toDecimal64OrZero).
* [`toDecimal64OrDefault`](#toDecimal64OrDefault).

**구문**

```sql theme={null}
toDecimal64OrNull(expr, S)
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현식을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)
* `S` — 숫자의 소수부에 허용되는 자릿수를 지정하는 0에서 18 사이의 스케일 매개변수입니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 Decimal(18, S) 값을 반환하고, 그렇지 않으면 `NULL`을 반환합니다. [`Decimal64(S)`](/ko/reference/data-types/decimal) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDecimal64OrNull('42.7', 2), toDecimal64OrNull('invalid', 2)
```

```response title=Response theme={null}
┌─toDecimal64OrNull('42.7', 2)─┬─toDecimal64OrNull('invalid', 2)─┐
│                        42.70 │                            ᴺᵁᴸᴸ │
└──────────────────────────────┴─────────────────────────────────┘
```

<div id="toDecimal64OrZero">
  ## toDecimal64OrZero
</div>

도입 버전: v20.1.0

입력 값을 [Decimal(18, S)](/ko/reference/data-types/decimal) 타입의 값으로 변환하되, 오류가 발생하면 `0`을 반환합니다.
[`toDecimal64`](#toDecimal64)와 유사하지만, 변환 오류가 발생할 때 예외를 발생시키는 대신 `0`을 반환합니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 해당 값의 문자열 표현.
* Float\* 타입의 값 또는 해당 값의 문자열 표현.

지원되지 않는 인수(`0` 반환):

* Float\* 타입 값 `NaN` 및 `Inf` 또는 해당 값의 문자열 표현(대소문자 구분 없음).
* 2진수 및 16진수 값의 문자열 표현.

<Note>
  입력 값이 `Decimal64`의 범위 `(-1*10^(18 - S), 1*10^(18 - S))`를 초과하면 함수는 `0`을 반환합니다.
</Note>

관련 항목:

* [`toDecimal64`](#toDecimal64).
* [`toDecimal64OrNull`](#toDecimal64OrNull).
* [`toDecimal64OrDefault`](#toDecimal64OrDefault).

**구문**

```sql theme={null}
toDecimal64OrZero(expr, S)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식. [`표현식`](/ko/reference/data-types/special-data-types/expression)
* `S` — 숫자 소수부의 자릿수를 지정하는 0\~18 범위의 스케일 매개변수. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 Decimal(18, S) 값을 반환하며, 그렇지 않으면 `0`을 반환합니다. [`Decimal64(S)`](/ko/reference/data-types/decimal)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toDecimal64OrZero('42.7', 2), toDecimal64OrZero('invalid', 2)
```

```response title=Response theme={null}
┌─toDecimal64OrZero('42.7', 2)─┬─toDecimal64OrZero('invalid', 2)─┐
│                        42.70 │                            0.00 │
└──────────────────────────────┴─────────────────────────────────┘
```

<div id="toDecimalString">
  ## toDecimalString
</div>

도입 버전: v23.3.0

숫자 값을 지정된 소수 자릿수를 갖는 String으로 변환합니다.

이 함수는 입력 값을 지정된 소수 자릿수로 반올림합니다. 입력 값의 소수 자릿수가 요청한 자릿수보다 적으면 결과는
지정한 소수 자릿수에 정확히 맞도록 0으로 채워집니다.

**구문**

```sql theme={null}
toDecimalString(number, scale)
```

**인수**

* `number` — 문자열로 변환할 숫자 값입니다. 모든 숫자 타입(Int, UInt, Float, Decimal)을 사용할 수 있습니다. [`Int8`](/ko/reference/data-types/int-uint) or [`Int16`](/ko/reference/data-types/int-uint) or [`Int32`](/ko/reference/data-types/int-uint) or [`Int64`](/ko/reference/data-types/int-uint) or [`UInt8`](/ko/reference/data-types/int-uint) or [`UInt16`](/ko/reference/data-types/int-uint) or [`UInt32`](/ko/reference/data-types/int-uint) or [`UInt64`](/ko/reference/data-types/int-uint) or [`Float32`](/ko/reference/data-types/float) or [`Float64`](/ko/reference/data-types/float) or [`Decimal`](/ko/reference/data-types/decimal)
* `scale` — 소수부에 표시할 자릿수입니다. 필요한 경우 결과는 반올림됩니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

지정한 소수 자릿수를 정확히 갖는 숫자의 String 표현을 반환합니다. [`String`](/ko/reference/data-types/string)

**예시**

**숫자를 반올림하고 포맷 지정**

```sql title=Query theme={null}
SELECT toDecimalString(2.1456, 2)
```

```response title=Response theme={null}
┌─toDecimalString(2.1456, 2)─┐
│ 2.15                       │
└────────────────────────────┘
```

**0으로 채우기**

```sql title=Query theme={null}
SELECT toDecimalString(5, 3)
```

```response title=Response theme={null}
┌─toDecimalString(5, 3)─┐
│ 5.000                 │
└───────────────────────┘
```

**다양한 숫자 타입**

```sql title=Query theme={null}
SELECT toDecimalString(CAST(123.456 AS Decimal(10,3)), 2) AS decimal_val,
       toDecimalString(CAST(42.7 AS Float32), 4) AS float_val
```

```response title=Response theme={null}
┌─decimal_val─┬─float_val─┐
│ 123.46      │ 42.7000   │
└─────────────┴───────────┘
```

<div id="toFixedString">
  ## toFixedString
</div>

도입 버전: v1.1.0

[`String`](/ko/reference/data-types/string) 인수를 [`FixedString(N)`](/ko/reference/data-types/fixedstring) 타입(길이가 N으로 고정된 문자열)으로 변환합니다.

문자열의 바이트 수가 N보다 적으면 오른쪽에 null byte가 채워집니다.
문자열의 바이트 수가 N보다 많으면 예외가 발생합니다.

**구문**

```sql theme={null}
toFixedString(s, N)
```

**인수**

* `s` — 변환할 문자열입니다. [`String`](/ko/reference/data-types/string)
* `N` — 생성되는 FixedString의 길이입니다. [`const UInt*`](/ko/reference/data-types/int-uint)

**반환 값**

길이가 N인 FixedString을 반환합니다. [`FixedString(N)`](/ko/reference/data-types/fixedstring)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toFixedString('foo', 8) AS s;
```

```response title=Response theme={null}
┌─s─────────────┐
│ foo\0\0\0\0\0 │
└───────────────┘
```

<div id="toFloat32">
  ## toFloat32
</div>

도입 버전: v1.1.0

입력값을 [Float32](/ko/reference/data-types/float) 타입의 값으로 변환합니다.
오류가 발생하면 예외를 발생시킵니다.

지원되는 인수:

* (U)Int\* 타입 값.
* (U)Int8/16/32/128/256의 문자열 표현.
* `NaN` 및 `Inf`를 포함한 Float\* 타입 값.
* `NaN` 및 `Inf`를 포함한 Float\*의 문자열 표현(대소문자 구분 없음).

지원되지 않는 인수:

* 이진수 및 16진수 값의 문자열 표현. 예: `SELECT toFloat32('0xc0fe');`.

관련 항목:

* [`toFloat32OrZero`](#toFloat32OrZero).
* [`toFloat32OrNull`](#toFloat32OrNull).
* [`toFloat32OrDefault`](#toFloat32OrDefault).

**구문**

```sql theme={null}
toFloat32(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

32비트 부동소수점 값을 반환합니다. [`Float32`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toFloat32(42.7),
    toFloat32('42.7'),
    toFloat32('NaN')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toFloat32(42.7):   42.7
toFloat32('42.7'): 42.7
toFloat32('NaN'):  nan
```

<div id="toFloat32OrDefault">
  ## toFloat32OrDefault
</div>

도입 버전: v21.11.0

[`toFloat32`](#toFloat32)와 마찬가지로, 이 함수는 입력값을 [Float32](/ko/reference/data-types/float) 타입의 값으로 변환하지만 오류가 발생하면 기본값을 반환합니다.
`default` 값이 전달되지 않으면 오류가 발생할 때 `0`을 반환합니다.

**구문**

```sql theme={null}
toFloat32OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패할 경우 반환할 기본값입니다. [`Float32`](/ko/reference/data-types/float)

**반환 값**

성공하면 Float32 타입의 값을 반환하고, 실패하면 인수로 전달된 기본값을 반환하며 기본값이 없으면 0을 반환합니다. [`Float32`](/ko/reference/data-types/float)

**예시**

**성공적인 변환**

```sql title=Query theme={null}
SELECT toFloat32OrDefault('8', CAST('0', 'Float32'))
```

```response title=Response theme={null}
8
```

**변환 실패**

```sql title=Query theme={null}
SELECT toFloat32OrDefault('abc', CAST('0', 'Float32'))
```

```response title=Response theme={null}
0
```

<div id="toFloat32OrNull">
  ## toFloat32OrNull
</div>

도입 버전: v1.1.0

입력값을 [Float32](/ko/reference/data-types/float) 타입 값으로 변환하며, 오류가 발생하면 `NULL`을 반환합니다.
[`toFloat32`](#toFloat32)와 유사하지만, 변환 오류 발생 시 예외를 발생시키는 대신 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\* 타입의 값.
* (U)Int8/16/32/128/256의 문자열 표현.
* `NaN` 및 `Inf`를 포함한 Float\* 타입의 값.
* `NaN` 및 `Inf`를 포함한 Float\*의 문자열 표현(대소문자 구분 없음).

지원되지 않는 인수(`NULL` 반환):

* 이진수 및 16진수 값의 문자열 표현(예: `SELECT toFloat32OrNull('0xc0fe');`).
* 잘못된 문자열 포맷.

관련 항목:

* [`toFloat32`](#toFloat32).
* [`toFloat32OrZero`](#toFloat32OrZero).
* [`toFloat32OrDefault`](#toFloat32OrDefault).

**구문**

```sql theme={null}
toFloat32OrNull(x)
```

**인수**

* `x` — 숫자를 문자열로 표현한 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 32비트 Float 값을 반환하고, 그렇지 않으면 `NULL`을 반환합니다. [`Float32`](/ko/reference/data-types/float) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toFloat32OrNull('42.7'),
    toFloat32OrNull('NaN'),
    toFloat32OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toFloat32OrNull('42.7'): 42.7
toFloat32OrNull('NaN'):  nan
toFloat32OrNull('abc'):  \N
```

<div id="toFloat32OrZero">
  ## toFloat32OrZero
</div>

도입 버전: v1.1.0

입력 값을 [Float32](/ko/reference/data-types/float) 타입의 값으로 변환하며, 오류가 발생하면 `0`을 반환합니다.
[`toFloat32`](#toFloat32)와 비슷하지만, 변환 오류가 발생해도 예외를 발생시키지 않고 `0`을 반환합니다.

관련 항목:

* [`toFloat32`](#toFloat32).
* [`toFloat32OrNull`](#toFloat32OrNull).
* [`toFloat32OrDefault`](#toFloat32OrDefault).

**구문**

```sql theme={null}
toFloat32OrZero(x)
```

**인수**

* `x` — 숫자를 문자열로 나타낸 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 32비트 Float 값을 반환하고, 그렇지 않으면 `0`을 반환합니다. [`Float32`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toFloat32OrZero('42.7'),
    toFloat32OrZero('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toFloat32OrZero('42.7'): 42.7
toFloat32OrZero('abc'):  0
```

<div id="toFloat64">
  ## toFloat64
</div>

도입 버전: v1.1.0

입력값을 [`Float64`](/ko/reference/data-types/float) 타입의 값으로 변환합니다.
오류가 발생하는 경우 예외를 발생시킵니다.

지원되는 인수:

* (U)Int\* 타입 값.
* (U)Int8/16/32/128/256의 문자열 표현.
* `NaN` 및 `Inf`를 포함한 Float\* 타입 값.
* `NaN` 및 `Inf`를 포함한 Float\* 타입의 문자열 표현(대소문자 구분 없음).

지원되지 않는 인수:

* 이진수 및 16진수 값의 문자열 표현. 예: `SELECT toFloat64('0xc0fe');`.

관련 항목:

* [`toFloat64OrZero`](#toFloat64OrZero).
* [`toFloat64OrNull`](#toFloat64OrNull).
* [`toFloat64OrDefault`](#toFloat64OrDefault).

**구문**

```sql theme={null}
toFloat64(expr)
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

64비트 부동소수점 값을 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toFloat64(42.7),
    toFloat64('42.7'),
    toFloat64('NaN')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toFloat64(42.7):   42.7
toFloat64('42.7'): 42.7
toFloat64('NaN'):  nan
```

<div id="toFloat64OrDefault">
  ## toFloat64OrDefault
</div>

도입 버전: v21.11.0

[`toFloat64`](#toFloat64)와 마찬가지로, 이 함수는 입력 값을 [Float64](/ko/reference/data-types/float) 타입으로 변환하지만 오류가 발생하면 기본값을 반환합니다.
`default` 값이 전달되지 않으면 오류 발생 시 `0`을 반환합니다.

**구문**

```sql theme={null}
toFloat64OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패할 경우 반환할 기본값입니다. [`Float64`](/ko/reference/data-types/float)

**반환 값**

성공하면 `Float64` 타입의 값을 반환하고, 실패하면 인수로 전달된 기본값을 반환하며, 기본값이 없으면 `0`을 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toFloat64OrDefault('8', CAST('0', 'Float64'))
```

```response title=Response theme={null}
8
```

**변환 실패**

```sql title=Query theme={null}
SELECT toFloat64OrDefault('abc', CAST('0', 'Float64'))
```

```response title=Response theme={null}
0
```

<div id="toFloat64OrNull">
  ## toFloat64OrNull
</div>

도입 버전: v1.1.0

입력 값을 [Float64](/ko/reference/data-types/float) 타입의 값으로 변환하며, 오류가 발생하면 `NULL`을 반환합니다.
[`toFloat64`](#toFloat64)와 같지만, 변환 오류가 발생했을 때 예외를 발생시키는 대신 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\* 타입의 값.
* 문자열로 표현된 (U)Int8/16/32/128/256.
* `NaN` 및 `Inf`를 포함한 Float\* 타입의 값.
* `NaN` 및 `Inf`를 포함한 Float\* 타입의 문자열 표현(대소문자 구분 없음).

지원되지 않는 인수(`NULL` 반환):

* 2진수 및 16진수 값의 문자열 표현(예: `SELECT toFloat64OrNull('0xc0fe');`).
* 잘못된 문자열 포맷.

관련 항목:

* [`toFloat64`](#toFloat64).
* [`toFloat64OrZero`](#toFloat64OrZero).
* [`toFloat64OrDefault`](#toFloat64OrDefault).

**구문**

```sql theme={null}
toFloat64OrNull(x)
```

**인수**

* `x` — 숫자를 문자열로 표현한 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공 시 64비트 Float 값을, 그렇지 않으면 `NULL`을 반환합니다. [`Float64`](/ko/reference/data-types/float) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toFloat64OrNull('42.7'),
    toFloat64OrNull('NaN'),
    toFloat64OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toFloat64OrNull('42.7'): 42.7
toFloat64OrNull('NaN'):  nan
toFloat64OrNull('abc'):  \N
```

<div id="toFloat64OrZero">
  ## toFloat64OrZero
</div>

도입 버전: v1.1.0

입력값을 [Float64](/ko/reference/data-types/float) 타입의 값으로 변환하되, 오류가 발생하면 `0`을 반환합니다.
[`toFloat64`](#toFloat64)와 유사하지만, 변환 오류 시 예외를 발생시키는 대신 `0`을 반환합니다.

관련 항목:

* [`toFloat64`](#toFloat64).
* [`toFloat64OrNull`](#toFloat64OrNull).
* [`toFloat64OrDefault`](#toFloat64OrDefault).

**구문**

```sql theme={null}
toFloat64OrZero(x)
```

**인수**

* `x` — 숫자를 문자열로 표현한 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 64비트 Float 값을 반환하고, 그렇지 않으면 `0`을 반환합니다. [`Float64`](/ko/reference/data-types/float)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toFloat64OrZero('42.7'),
    toFloat64OrZero('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toFloat64OrZero('42.7'): 42.7
toFloat64OrZero('abc'):  0
```

<div id="toInt128">
  ## toInt128
</div>

도입 버전: v1.1.0

입력 값을 [Int128](/ko/reference/data-types/int-uint) 타입의 값으로 변환합니다.
오류가 발생하면 예외를 발생시킵니다.
이 함수는 0을 향한 반올림을 사용하므로 숫자의 소수 자릿수는 버려집니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값.

지원되지 않는 인수:

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toInt128('0xc0fe');`.

<Note>
  입력 값을 Int128 범위 내에서 표현할 수 없으면 결과가 오버플로우 또는 언더플로우될 수 있습니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toInt128OrZero`](#toInt128OrZero).
* [`toInt128OrNull`](#toInt128OrNull).
* [`toInt128OrDefault`](#toInt128OrDefault).

**구문**

```sql theme={null}
toInt128(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

128비트 정수 값을 반환합니다. [`Int128`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt128(-128),
    toInt128(-128.8),
    toInt128('-128')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toInt128(-128):   -128
toInt128(-128.8): -128
toInt128('-128'): -128
```

<div id="toInt128OrDefault">
  ## toInt128OrDefault
</div>

도입 버전: v21.11.0

이 함수는 [`toInt128`](#toInt128)와 마찬가지로 입력 값을 [Int128](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생하면 기본값을 반환합니다.
`default` 값을 전달하지 않으면 오류가 발생할 때 `0`을 반환합니다.

**구문**

```sql theme={null}
toInt128OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패한 경우 반환할 기본값입니다. [`Int128`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 `Int128` 타입의 값을 반환합니다. 실패하면 인수로 전달된 기본값을 반환하고, 기본값이 전달되지 않았으면 `0`을 반환합니다. [`Int128`](/ko/reference/data-types/int-uint)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toInt128OrDefault('-128', CAST('-1', 'Int128'))
```

```response title=Response theme={null}
-128
```

**변환 실패**

```sql title=Query theme={null}
SELECT toInt128OrDefault('abc', CAST('-1', 'Int128'))
```

```response title=Response theme={null}
-1
```

<div id="toInt128OrNull">
  ## toInt128OrNull
</div>

도입 버전: v20.8.0

[`toInt128`](#toInt128)와 마찬가지로, 이 함수는 입력값을 [Int128](/ko/reference/data-types/int-uint) 타입 값으로 변환하지만, 오류가 발생하는 경우 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 표현.

지원되지 않는 인수(`NULL` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현(예: `SELECT toInt128OrNull('0xc0fe');`).

<Note>
  입력값을 [Int128](/ko/reference/data-types/int-uint) 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toInt128`](#toInt128).
* [`toInt128OrZero`](#toInt128OrZero).
* [`toInt128OrDefault`](#toInt128OrDefault).

**구문**

```sql theme={null}
toInt128OrNull(x)
```

**인수**

* `x` — 숫자를 나타내는 String입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`Int128` 유형의 값을 반환합니다. 변환에 실패하면 `NULL`을 반환합니다. [`Int128`](/ko/reference/data-types/int-uint) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt128OrNull('-128'),
    toInt128OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toInt128OrNull('-128'): -128
toInt128OrNull('abc'):  \N
```

<div id="toInt128OrZero">
  ## toInt128OrZero
</div>

도입 버전: v20.8.0

입력 값을 [Int128](/ko/reference/data-types/int-uint) 타입으로 변환하지만, 오류가 발생한 경우 `0`을 반환합니다.
[`toInt128`](#toInt128)와 비슷하지만 예외를 발생시키는 대신 `0`을 반환합니다.

관련 항목:

* [`toInt128`](#toInt128).
* [`toInt128OrNull`](#toInt128OrNull).
* [`toInt128OrDefault`](#toInt128OrDefault).

**구문**

```sql theme={null}
toInt128OrZero(x)
```

**인수**

* `x` — 변환할 입력 값입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Decimal`](/ko/reference/data-types/decimal) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime)

**반환 값**

변환된 입력 값을 반환하며, 변환에 실패하면 `0`을 반환합니다. [`Int128`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toInt128OrZero('123')
```

```response title=Response theme={null}
123
```

**변환이 실패하면 0을 반환합니다**

```sql title=Query theme={null}
SELECT toInt128OrZero('abc')
```

```response title=Response theme={null}
0
```

<div id="toInt16">
  ## toInt16
</div>

도입 버전: v1.1.0

입력 값을 [`Int16`](/ko/reference/data-types/int-uint) 타입의 값으로 변환합니다.
오류가 발생하면 예외를 발생시킵니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 해당 값을 나타내는 문자열 표현.
* Float\* 타입의 값.

지원되지 않는 인수:

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toInt16('0xc0fe');`.

<Note>
  입력 값을 [Int16](/ko/reference/data-types/int-uint)의 범위 내로 표현할 수 없으면 결과에서 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
  예: `SELECT toInt16(32768) == -32768;`.
</Note>

<Note>
  이 함수는 [0을 향한 반올림](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero)을 사용하므로 숫자의 소수 자릿수를 잘라냅니다.
</Note>

관련 항목:

* [`toInt16OrZero`](#toInt16OrZero).
* [`toInt16OrNull`](#toInt16OrNull).
* [`toInt16OrDefault`](#toInt16OrDefault).

**구문**

```sql theme={null}
toInt16(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식입니다. [`Expression`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

16비트 정수 값을 반환합니다. [`Int16`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt16(-16),
    toInt16(-16.16),
    toInt16('-16')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toInt16(-16):    -16
toInt16(-16.16): -16
toInt16('-16'):  -16
```

<div id="toInt16OrDefault">
  ## toInt16OrDefault
</div>

도입 버전: v21.11.0

[`toInt16`](#toInt16)와 마찬가지로, 이 함수는 입력값을 [Int16](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만 오류가 발생하면 기본값을 반환합니다.
`default` 값이 전달되지 않으면 오류가 발생할 때 `0`을 반환합니다.

**구문**

```sql theme={null}
toInt16OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패할 경우 반환할 기본값입니다. [`Int16`](/ko/reference/data-types/int-uint)

**반환 값**

성공 시 Int16 타입의 값을 반환합니다. 실패 시 인수가 전달되면 기본값을, 전달되지 않으면 0을 반환합니다. [`Int16`](/ko/reference/data-types/int-uint)

**예시**

**성공적인 변환**

```sql title=Query theme={null}
SELECT toInt16OrDefault('-16', CAST('-1', 'Int16'))
```

```response title=Response theme={null}
-16
```

**변환 실패**

```sql title=Query theme={null}
SELECT toInt16OrDefault('abc', CAST('-1', 'Int16'))
```

```response title=Response theme={null}
-1
```

<div id="toInt16OrNull">
  ## toInt16OrNull
</div>

도입 버전: v1.1.0

[`toInt16`](#toInt16)와 마찬가지로, 이 함수는 입력값을 [Int16](/ko/reference/data-types/int-uint) 타입의 값으로 변환하며, 오류가 발생하면 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 표현.

지원되지 않는 인수(`NULL` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toInt16OrNull('0xc0fe');`.

<Note>
  입력값을 [Int16](/ko/reference/data-types/int-uint) 범위 내에서 표현할 수 없으면 결과에서 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toInt16`](#toInt16).
* [`toInt16OrZero`](#toInt16OrZero).
* [`toInt16OrDefault`](#toInt16OrDefault).

**구문**

```sql theme={null}
toInt16OrNull(x)
```

**인수**

* `x` — 숫자를 문자열로 표현한 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`Int16` 유형의 값을 반환합니다. 변환에 실패하면 `NULL`을 반환합니다. [`Int16`](/ko/reference/data-types/int-uint) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt16OrNull('-16'),
    toInt16OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toInt16OrNull('-16'): -16
toInt16OrNull('abc'): \N
```

<div id="toInt16OrZero">
  ## toInt16OrZero
</div>

도입 버전: v1.1.0

[`toInt16`](#toInt16)와 마찬가지로, 이 함수는 입력 값을 [Int16](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생할 경우 `0`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 형식.

지원되지 않는 인수(`0` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 형식.
* 2진수 및 16진수 값의 문자열 형식. 예: `SELECT toInt16OrZero('0xc0fe');`.

<Note>
  입력 값을 [Int16](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toInt16`](#toInt16).
* [`toInt16OrNull`](#toInt16OrNull).
* [`toInt16OrDefault`](#toInt16OrDefault).

**구문**

```sql theme={null}
toInt16OrZero(x)
```

**인수**

* `x` — 숫자를 `String`으로 표현한 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`Int16` 타입의 값을 반환하며, 변환에 실패하면 `0`을 반환합니다. [`Int16`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt16OrZero('16'),
    toInt16OrZero('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toInt16OrZero('16'): 16
toInt16OrZero('abc'): 0
```

<div id="toInt256">
  ## toInt256
</div>

도입 버전: v1.1.0

입력 값을 [Int256](/ko/reference/data-types/int-uint) 타입의 값으로 변환합니다.
오류가 발생한 경우 예외를 발생시킵니다.
이 함수는 0 방향으로 버림을 수행하므로 숫자의 소수 자릿수를 잘라냅니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값.

지원되지 않는 인수:

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현(예: `SELECT toInt256('0xc0fe');`).

<Note>
  입력 값을 Int256 범위 내에 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toInt256OrZero`](#toInt256OrZero).
* [`toInt256OrNull`](#toInt256OrNull).
* [`toInt256OrDefault`](#toInt256OrDefault).

**구문**

```sql theme={null}
toInt256(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

256비트 정수 값을 반환합니다. [`Int256`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt256(-256),
    toInt256(-256.256),
    toInt256('-256')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toInt256(-256):     -256
toInt256(-256.256): -256
toInt256('-256'):   -256
```

<div id="toInt256OrDefault">
  ## toInt256OrDefault
</div>

도입 버전: v21.11.0

[`toInt256`](#toInt256)와 마찬가지로, 이 함수는 입력 값을 [Int256](/ko/reference/data-types/int-uint) 타입으로 변환하지만 오류가 발생하면 기본값을 반환합니다.
`default` 값을 전달하지 않으면 오류 발생 시 `0`을 반환합니다.

**구문**

```sql theme={null}
toInt256OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패할 경우 반환할 기본값입니다. [`Int256`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 `Int256` 타입의 값을 반환합니다. 실패하면 `default`가 전달된 경우 해당 기본값을 반환하고, 전달되지 않은 경우 0을 반환합니다. [`Int256`](/ko/reference/data-types/int-uint)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toInt256OrDefault('-256', CAST('-1', 'Int256'))
```

```response title=Response theme={null}
-256
```

**변환 실패**

```sql title=Query theme={null}
SELECT toInt256OrDefault('abc', CAST('-1', 'Int256'))
```

```response title=Response theme={null}
-1
```

<div id="toInt256OrNull">
  ## toInt256OrNull
</div>

도입 버전: v20.8.0

[`toInt256`](#toInt256)와 마찬가지로, 이 함수는 입력값을 [Int256](/ko/reference/data-types/int-uint) 타입 값으로 변환하지만 오류가 발생한 경우 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 표현.

지원되지 않는 인수(`NULL` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toInt256OrNull('0xc0fe');`.

<Note>
  입력값을 [Int256](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toInt256`](#toInt256).
* [`toInt256OrZero`](#toInt256OrZero).
* [`toInt256OrDefault`](#toInt256OrDefault).

**구문**

```sql theme={null}
toInt256OrNull(x)
```

**인수**

* `x` — 숫자를 나타내는 String 형식의 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

Int256 타입의 값을 반환합니다. 변환에 실패하면 `NULL`을 반환합니다. [`Int256`](/ko/reference/data-types/int-uint) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt256OrNull('-256'),
    toInt256OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
행 1:
──────
toInt256OrNull('-256'): -256
toInt256OrNull('abc'):  \N
```

<div id="toInt256OrZero">
  ## toInt256OrZero
</div>

도입 버전: v20.8.0

입력값을 [Int256](/ko/reference/data-types/int-uint) 타입으로 변환하며, 오류가 발생하면 `0`을 반환합니다.
[`toInt256`](#toInt256)와 유사하지만, 예외를 발생시키는 대신 `0`을 반환합니다.

관련 항목:

* [`toInt256`](#toInt256).
* [`toInt256OrNull`](#toInt256OrNull).
* [`toInt256OrDefault`](#toInt256OrDefault).

**구문**

```sql theme={null}
toInt256OrZero(x)
```

**인수**

* `x` — 변환할 입력값입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Decimal`](/ko/reference/data-types/decimal) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime)

**반환 값**

변환된 입력값을 반환합니다. 변환에 실패하면 `0`을 반환합니다. [`Int256`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toInt256OrZero('123')
```

```response title=Response theme={null}
123
```

**변환이 실패하면 0을 반환합니다**

```sql title=Query theme={null}
SELECT toInt256OrZero('abc')
```

```response title=Response theme={null}
0
```

<div id="toInt32">
  ## toInt32
</div>

도입 버전: v1.1.0

입력값을 [`Int32`](/ko/reference/data-types/int-uint) 타입의 값으로 변환합니다.
오류가 발생하면 예외를 발생시킵니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 해당 타입의 문자열 표현.
* Float\* 타입의 값.

지원되지 않는 인수:

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현(예: `SELECT toInt32('0xc0fe');`).

<Note>
  입력값을 [Int32](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없으면 결과는 오버플로우 또는 언더플로우될 수 있습니다.
  이는 오류로 간주되지 않습니다.
  예시: `SELECT toInt32(2147483648) == -2147483648;`
</Note>

<Note>
  이 함수는 [0을 향한 반올림](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero)를 사용하므로 숫자의 소수 자릿수를 버립니다.
</Note>

관련 항목:

* [`toInt32OrZero`](#toInt32OrZero).
* [`toInt32OrNull`](#toInt32OrNull).
* [`toInt32OrDefault`](#toInt32OrDefault).

**구문**

```sql theme={null}
toInt32(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 나타낸 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

32비트 정수 값을 반환합니다. [`Int32`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt32(-32),
    toInt32(-32.32),
    toInt32('-32')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toInt32(-32):    -32
toInt32(-32.32): -32
toInt32('-32'):  -32
```

<div id="toInt32OrDefault">
  ## toInt32OrDefault
</div>

도입 버전: v21.11.0

[`toInt32`](#toInt32)와 마찬가지로, 이 함수는 입력 값을 [Int32](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만 오류가 발생하면 기본값을 반환합니다.
`default` 값이 전달되지 않으면 오류가 발생한 경우 `0`을 반환합니다.

**구문**

```sql theme={null}
toInt32OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패한 경우 반환할 기본값입니다. [`Int32`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 `Int32` 타입의 값을 반환합니다. 실패하면 `default`가 전달된 경우 해당 값을, 그렇지 않으면 `0`을 반환합니다. [`Int32`](/ko/reference/data-types/int-uint)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toInt32OrDefault('-32', CAST('-1', 'Int32'))
```

```response title=Response theme={null}
-32
```

**변환 실패**

```sql title=Query theme={null}
SELECT toInt32OrDefault('abc', CAST('-1', 'Int32'))
```

```response title=Response theme={null}
-1
```

<div id="toInt32OrNull">
  ## toInt32OrNull
</div>

도입 버전: v1.1.0

[`toInt32`](#toInt32)와 마찬가지로, 이 함수는 입력값을 [Int32](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만 오류가 발생할 경우 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 표현.

지원되지 않는 인수 (`NULL` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현(예: `SELECT toInt32OrNull('0xc0fe');`).

<Note>
  입력값을 [Int32](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없는 경우 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toInt32`](#toInt32).
* [`toInt32OrZero`](#toInt32OrZero).
* [`toInt32OrDefault`](#toInt32OrDefault).

**구문**

```sql theme={null}
toInt32OrNull(x)
```

**인수**

* `x` — 숫자를 나타내는 String입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`Int32` 타입의 값을 반환합니다. 변환에 실패하면 `NULL`을 반환합니다. [`Int32`](/ko/reference/data-types/int-uint) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt32OrNull('-32'),
    toInt32OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
행 1:
──────
toInt32OrNull('-32'): -32
toInt32OrNull('abc'): \N
```

<div id="toInt32OrZero">
  ## toInt32OrZero
</div>

도입 버전: v1.1.0

[`toInt32`](#toInt32)와 마찬가지로, 이 함수는 입력값을 [Int32](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만 오류 시 `0`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 표현.

지원되지 않는 인수 (`0` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현(예: `SELECT toInt32OrZero('0xc0fe');`).

<Note>
  입력값을 [Int32](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toInt32`](#toInt32).
* [`toInt32OrNull`](#toInt32OrNull).
* [`toInt32OrDefault`](#toInt32OrDefault).

**구문**

```sql theme={null}
toInt32OrZero(x)
```

**인수**

* `x` — 숫자를 문자열로 나타낸 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

Int32 타입의 값을 반환합니다. 변환에 실패하면 `0`을 반환합니다. [`Int32`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt32OrZero('32'),
    toInt32OrZero('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toInt32OrZero('32'): 32
toInt32OrZero('abc'): 0
```

<div id="toInt64">
  ## toInt64
</div>

도입 버전: v1.1.0

입력 값을 [`Int64`](/ko/reference/data-types/int-uint) 타입의 값으로 변환합니다.
오류가 발생하면 예외를 발생시킵니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 해당 값의 문자열 표현.
* Float\* 타입의 값.

지원되지 않는 인수:

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toInt64('0xc0fe');`.

<Note>
  입력 값을 [Int64](/ko/reference/data-types/int-uint) 범위 내에서 표현할 수 없으면 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
  예시: `SELECT toInt64(9223372036854775808) == -9223372036854775808;`
</Note>

<Note>
  이 함수는 [0을 향한 반올림](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero)을 사용하므로 숫자의 소수 자릿수를 잘라냅니다.
</Note>

관련 항목:

* [`toInt64OrZero`](#toInt64OrZero).
* [`toInt64OrNull`](#toInt64OrNull).
* [`toInt64OrDefault`](#toInt64OrDefault).

**구문**

```sql theme={null}
toInt64(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식입니다. 지원: (U)Int\* 타입의 값 또는 해당 값의 문자열 표현, Float\* 타입의 값. 미지원: NaN 및 Inf를 포함한 Float\* 값의 문자열 표현, binary 및 hexadecimal 값의 문자열 표현. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

64비트 정수 값을 반환합니다. [`Int64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt64(-64),
    toInt64(-64.64),
    toInt64('-64')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toInt64(-64):    -64
toInt64(-64.64): -64
toInt64('-64'):  -64
```

<div id="toInt64OrDefault">
  ## toInt64OrDefault
</div>

도입 버전: v21.11.0

[`toInt64`](#toInt64)와 마찬가지로, 이 함수는 입력 값을 [Int64](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만 오류가 발생하면 기본값을 반환합니다.
`default` 값이 전달되지 않으면 오류 발생 시 `0`을 반환합니다.

**구문**

```sql theme={null}
toInt64OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 나타낸 값을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패할 경우 반환할 기본값입니다. [`Int64`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 `Int64` 타입의 값을 반환하고, 실패하면 인수로 전달된 기본값을 반환하며, 기본값이 없으면 0을 반환합니다. [`Int64`](/ko/reference/data-types/int-uint)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toInt64OrDefault('-64', CAST('-1', 'Int64'))
```

```response title=Response theme={null}
-64
```

**변환 실패**

```sql title=Query theme={null}
SELECT toInt64OrDefault('abc', CAST('-1', 'Int64'))
```

```response title=Response theme={null}
-1
```

<div id="toInt64OrNull">
  ## toInt64OrNull
</div>

도입 버전: v1.1.0

[`toInt64`](#toInt64)와 마찬가지로, 이 함수는 입력값을 [Int64](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생한 경우 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 표현.

지원되지 않는 인수 (`NULL` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toInt64OrNull('0xc0fe');`.

<Note>
  입력값을 [Int64](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toInt64`](#toInt64).
* [`toInt64OrZero`](#toInt64OrZero).
* [`toInt64OrDefault`](#toInt64OrDefault).

**구문**

```sql theme={null}
toInt64OrNull(x)
```

**인수**

* `x` — 숫자의 문자열 표현입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`Int64` 타입의 값을 반환하며, 변환에 실패하면 `NULL`을 반환합니다. [`Int64`](/ko/reference/data-types/int-uint) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt64OrNull('-64'),
    toInt64OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toInt64OrNull('-64'): -64
toInt64OrNull('abc'): \N
```

<div id="toInt64OrZero">
  ## toInt64OrZero
</div>

도입 버전: v1.1.0

입력 값을 [Int64](/ko/reference/data-types/int-uint) 타입으로 변환하며, 오류가 발생하면 `0`을 반환합니다.
[`toInt64`](#toInt64)와 같지만, 예외를 발생시키는 대신 `0`을 반환합니다.

관련 항목:

* [`toInt64`](#toInt64).
* [`toInt64OrNull`](#toInt64OrNull).
* [`toInt64OrDefault`](#toInt64OrDefault).

**구문**

```sql theme={null}
toInt64OrZero(x)
```

**인수**

* `x` — 변환할 입력값입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`Decimal`](/ko/reference/data-types/decimal) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime)

**반환 값**

변환된 입력값을 반환하며, 변환에 실패하면 `0`을 반환합니다. [`Int64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toInt64OrZero('123')
```

```response title=Response theme={null}
123
```

**변환이 실패하면 0을 반환합니다**

```sql title=Query theme={null}
SELECT toInt64OrZero('abc')
```

```response title=Response theme={null}
0
```

<div id="toInt8">
  ## toInt8
</div>

Introduced in: v1.1.0

입력값을 [`Int8`](/ko/reference/data-types/int-uint) 타입의 값으로 변환합니다.
오류가 발생하면 예외를 발생시킵니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값.

지원되지 않는 인수:

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현(예: `SELECT toInt8('0xc0fe');`).

<Note>
  입력값을 [Int8](/ko/reference/data-types/int-uint) 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
  예시: `SELECT toInt8(128) == -128;`.
</Note>

<Note>
  이 함수는 [rounding towards zero](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero) 방식을 사용하므로 숫자의 소수 자릿수를 버립니다.
</Note>

관련 항목:

* [`toInt8OrZero`](#toInt8OrZero).
* [`toInt8OrNull`](#toInt8OrNull).
* [`toInt8OrDefault`](#toInt8OrDefault).

**구문**

```sql theme={null}
toInt8(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 나타내는 문자열을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

8비트 정수 값을 반환합니다. [`Int8`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt8(-8),
    toInt8(-8.8),
    toInt8('-8')
FORMAT Vertical
```

```response title=Response theme={null}
행 1:
──────
toInt8(-8):   -8
toInt8(-8.8): -8
toInt8('-8'): -8
```

<div id="toInt8OrDefault">
  ## toInt8OrDefault
</div>

도입 버전: v21.11.0

[`toInt8`](#toInt8)와 마찬가지로, 이 함수는 입력값을 [Int8](/ko/reference/data-types/int-uint) 타입으로 변환하지만 오류가 발생하면 기본값을 반환합니다.
`default` 값이 전달되지 않으면 오류가 발생할 때 `0`을 반환합니다.

**구문**

```sql theme={null}
toInt8OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패할 경우 반환할 기본값입니다. [`Int8`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 Int8 타입의 값을 반환합니다. 실패하면 `default`가 전달된 경우 해당 기본값을 반환하고, 전달되지 않은 경우 0을 반환합니다. [`Int8`](/ko/reference/data-types/int-uint)

**예시**

**성공적인 변환**

```sql title=Query theme={null}
SELECT toInt8OrDefault('-8', CAST('-1', 'Int8'))
```

```response title=Response theme={null}
-8
```

**변환 실패**

```sql title=Query theme={null}
SELECT toInt8OrDefault('abc', CAST('-1', 'Int8'))
```

```response title=Response theme={null}
-1
```

<div id="toInt8OrNull">
  ## toInt8OrNull
</div>

도입 버전: v1.1.0

[`toInt8`](#toInt8)와 마찬가지로, 이 함수는 입력값을 [Int8](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생하면 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 표현.

지원되지 않는 인수(`NULL` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현(예: `SELECT toInt8OrNull('0xc0fe');`).

<Note>
  입력값을 [Int8](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toInt8`](#toInt8).
* [`toInt8OrZero`](#toInt8OrZero).
* [`toInt8OrDefault`](#toInt8OrDefault).

**구문**

```sql theme={null}
toInt8OrNull(x)
```

**인수**

* `x` — 숫자의 문자열 표현입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`Int8` 유형의 값을 반환합니다. 변환에 실패하면 `NULL`을 반환합니다. [`Int8`](/ko/reference/data-types/int-uint) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt8OrNull('-8'),
    toInt8OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
행 1:
──────
toInt8OrNull('-8'):  -8
toInt8OrNull('abc'): \N
```

<div id="toInt8OrZero">
  ## toInt8OrZero
</div>

도입 버전: v1.1.0

[`toInt8`](#toInt8)와 마찬가지로, 이 함수는 입력 값을 [Int8](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생하면 `0`을 반환합니다.

지원되는 인수:

* (U)Int\*를 문자열로 표현한 값.

지원되지 않는 인수(`0` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값을 문자열로 표현한 값.
* 2진수 및 16진수 값을 문자열로 표현한 값. 예: `SELECT toInt8OrZero('0xc0fe');`.

<Note>
  입력 값을 [Int8](/ko/reference/data-types/int-uint) 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toInt8`](#toInt8).
* [`toInt8OrNull`](#toInt8OrNull).
* [`toInt8OrDefault`](#toInt8OrDefault).

**구문**

```sql theme={null}
toInt8OrZero(x)
```

**인수**

* `x` — 숫자를 문자열로 표현한 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`Int8` 타입의 값을 반환합니다. 변환에 실패하면 `0`을 반환합니다. [`Int8`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toInt8OrZero('8'),
    toInt8OrZero('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toInt8OrZero('8'): 8
toInt8OrZero('abc'): 0
```

<div id="toInterval">
  ## toInterval
</div>

도입 버전: v25.4.0

숫자 값과 단위 문자열을 사용해 인터벌 값을 생성합니다.

이 함수는 단위를 문자열 인수로 지정해, 단일 함수로 다양한 타입의 인터벌(초, 분, 시간, 일, 주, 월, 분기, 연도)을 생성할 수 있도록 합니다.
단위 문자열은 대소문자를 구분하지 않습니다.

이 함수는 `toIntervalSecond`, `toIntervalMinute`, `toIntervalDay` 등의 타입별 함수를 호출하는 것과 동일하지만,
단위를 문자열 매개변수로 동적으로 지정할 수 있습니다.

**구문**

```sql theme={null}
toInterval(value, unit)
```

**인수**

* `value` — 단위의 개수를 나타내는 숫자 값입니다. 모든 숫자 타입이 될 수 있습니다. [`Int8`](/ko/reference/data-types/int-uint) 또는 [`Int16`](/ko/reference/data-types/int-uint) 또는 [`Int32`](/ko/reference/data-types/int-uint) 또는 [`Int64`](/ko/reference/data-types/int-uint) 또는 [`UInt8`](/ko/reference/data-types/int-uint) 또는 [`UInt16`](/ko/reference/data-types/int-uint) 또는 [`UInt32`](/ko/reference/data-types/int-uint) 또는 [`UInt64`](/ko/reference/data-types/int-uint) 또는 [`Float32`](/ko/reference/data-types/float) 또는 [`Float64`](/ko/reference/data-types/float)
* `unit` — 시간 단위입니다. 상수 문자열이어야 합니다. 유효한 값은 'nanosecond', 'microsecond', 'millisecond', 'second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

지정된 타입의 인터벌 값을 반환합니다. 결과 타입은 단위에 따라 달라집니다: IntervalNanosecond, IntervalMicrosecond, IntervalMillisecond, IntervalSecond, IntervalMinute, IntervalHour, IntervalDay, IntervalWeek, IntervalMonth, IntervalQuarter 또는 IntervalYear. [`Interval`](/ko/reference/data-types/int-uint)

**예시**

**서로 다른 단위의 인터벌 만들기**

```sql title=Query theme={null}
SELECT
    toInterval(5, 'second') AS seconds,
    toInterval(3, 'day') AS days,
    toInterval(2, 'month') AS months
```

```response title=Response theme={null}
┌─seconds─┬─days─┬─months─┐
│ 5       │ 3    │ 2      │
└─────────┴──────┴────────┘
```

**날짜 산술에 인터벌 사용하기**

```sql title=Query theme={null}
SELECT
    now() AS current_time,
    now() + toInterval(1, 'hour') AS one_hour_later,
    now() - toInterval(7, 'day') AS week_ago
```

```response title=Response theme={null}
┌─────────current_time─┬──one_hour_later─────┬────────────week_ago─┐
│ 2025-01-04 10:30:00  │ 2025-01-04 11:30:00 │ 2024-12-28 10:30:00 │
└──────────────────────┴─────────────────────┴─────────────────────┘
```

**동적 인터벌 생성**

```sql title=Query theme={null}
SELECT toDate('2025-01-01') + toInterval(number, 'day') AS dates
FROM numbers(5)
```

```response title=Response theme={null}
┌──────dates─┐
│ 2025-01-01 │
│ 2025-01-02 │
│ 2025-01-03 │
│ 2025-01-04 │
│ 2025-01-05 │
└────────────┘
```

<div id="toIntervalDay">
  ## toIntervalDay
</div>

도입 버전: v1.1.0

데이터 타입 [`IntervalDay`](/ko/reference/data-types/special-data-types/interval)의 `n`일 인터벌을 반환합니다.

**구문**

```sql theme={null}
toIntervalDay(n)
```

**인수**

* `n` — 일수입니다. 정수, 그 문자열 표현 또는 부동소수점 수입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`String`](/ko/reference/data-types/string)

**반환 값**

`n`일의 [`Interval`](/ko/reference/data-types/int-uint)을 반환합니다.

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH
    toDate('2025-06-15') AS date,
    toIntervalDay(5) AS interval_to_days
SELECT date + interval_to_days AS result
```

```response title=Response theme={null}
┌─────result─┐
│ 2025-06-20 │
└────────────┘
```

<div id="toIntervalHour">
  ## toIntervalHour
</div>

도입 버전: v1.1.0

데이터 타입 [`IntervalHour`](/ko/reference/data-types/special-data-types/interval)의 `n`시간 인터벌을 반환합니다.

**구문**

```sql theme={null}
toIntervalHour(n)
```

**인수**

* `n` — 시간 수입니다. 정수, 해당 값을 나타내는 문자열 또는 부동소수점 수를 사용할 수 있습니다. [`Int*`](/ko/reference/data-types/int-uint) 또는 [`UInt*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`String`](/ko/reference/data-types/string)

**반환 값**

`n`시간 인터벌을 반환합니다. [`Interval`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH
    toDate('2025-06-15') AS date,
    toIntervalHour(12) AS interval_to_hours
SELECT date + interval_to_hours AS result
```

```response title=Response theme={null}
┌──────────────result─┐
│ 2025-06-15 12:00:00 │
└─────────────────────┘
```

<div id="toIntervalMicrosecond">
  ## toIntervalMicrosecond
</div>

도입 버전: v22.6.0

`n` 마이크로초를 나타내는 [`IntervalMicrosecond`](/ko/reference/data-types/special-data-types/interval) 데이터 타입의 인터벌을 반환합니다.

**구문**

```sql theme={null}
toIntervalMicrosecond(n)
```

**인수**

* `n` — 마이크로초 단위의 수입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`String`](/ko/reference/data-types/string)

**반환 값**

`n` 마이크로초를 나타내는 인터벌을 반환합니다. [`Interval`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH
    toDateTime('2025-06-15') AS date,
    toIntervalMicrosecond(30) AS interval_to_microseconds
SELECT date + interval_to_microseconds AS result
```

```response title=Response theme={null}
┌─────────────────────result─┐
│ 2025-06-15 00:00:00.000030 │
└────────────────────────────┘
```

<div id="toIntervalMillisecond">
  ## toIntervalMillisecond
</div>

도입 버전: v22.6.0

데이터 타입 [IntervalMillisecond](/ko/reference/data-types/special-data-types/interval)의 `n`밀리초 인터벌을 반환합니다.

**구문**

```sql theme={null}
toIntervalMillisecond(n)
```

**인수**

* `n` — 밀리초 단위의 수입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`String`](/ko/reference/data-types/string)

**반환 값**

`n` 밀리초의 인터벌을 반환합니다. [`Interval`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH
    toDateTime('2025-06-15') AS date,
    toIntervalMillisecond(30) AS interval_to_milliseconds
SELECT date + interval_to_milliseconds AS result
```

```response title=Response theme={null}
┌──────────────────result─┐
│ 2025-06-15 00:00:00.030 │
└─────────────────────────┘
```

<div id="toIntervalMinute">
  ## toIntervalMinute
</div>

도입 버전: v1.1.0

데이터 타입(data type) [`IntervalMinute`](/ko/reference/data-types/special-data-types/interval)의 `n`분에 해당하는 인터벌을 반환합니다.

**구문**

```sql theme={null}
toIntervalMinute(n)
```

**인수**

* `n` — 분 단위 수입니다. 정수 또는 그 문자열 표현, 그리고 부동소수점 수를 사용할 수 있습니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`String`](/ko/reference/data-types/string)

**반환 값**

`n`분의 인터벌을 반환합니다. [`Interval`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH
    toDate('2025-06-15') AS date,
    toIntervalMinute(12) AS interval_to_minutes
SELECT date + interval_to_minutes AS result
```

```response title=Response theme={null}
┌──────────────result─┐
│ 2025-06-15 00:12:00 │
└─────────────────────┘
```

<div id="toIntervalMonth">
  ## toIntervalMonth
</div>

도입 버전: v1.1.0

데이터 타입 [`IntervalMonth`](/ko/reference/data-types/special-data-types/interval)의 `n`개월을 나타내는 인터벌을 반환합니다.

**구문**

```sql theme={null}
toIntervalMonth(n)
```

**인수**

* `n` — 개월 수. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`String`](/ko/reference/data-types/string)

**반환 값**

`n`개월에 해당하는 인터벌을 반환합니다. [`Interval`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH
    toDate('2025-06-15') AS date,
    toIntervalMonth(1) AS interval_to_month
SELECT date + interval_to_month AS result
```

```response title=Response theme={null}
┌─────result─┐
│ 2025-07-15 │
└────────────┘
```

<div id="toIntervalNanosecond">
  ## toIntervalNanosecond
</div>

도입 버전: v22.6.0

데이터 타입 [`IntervalNanosecond`](/ko/reference/data-types/special-data-types/interval)의 `n`나노초 인터벌을 반환합니다.

**구문**

```sql theme={null}
toIntervalNanosecond(n)
```

**인수**

* `n` — 나노초 단위의 수입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`String`](/ko/reference/data-types/string)

**반환 값**

`n`나노초의 인터벌을 반환합니다. [`Interval`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH
    toDateTime('2025-06-15') AS date,
    toIntervalNanosecond(30) AS interval_to_nanoseconds
SELECT date + interval_to_nanoseconds AS result
```

```response title=Response theme={null}
┌────────────────────────result─┐
│ 2025-06-15 00:00:00.000000030 │
└───────────────────────────────┘
```

<div id="toIntervalQuarter">
  ## toIntervalQuarter
</div>

도입 버전: v1.1.0

데이터 타입 [`IntervalQuarter`](/ko/reference/data-types/special-data-types/interval)의 `n`개 분기 인터벌을 반환합니다.

**구문**

```sql theme={null}
toIntervalQuarter(n)
```

**인수**

* `n` — 분기 수입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`String`](/ko/reference/data-types/string)

**반환 값**

`n`개 분기를 나타내는 인터벌을 반환합니다. [`Interval`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH
    toDate('2025-06-15') AS date,
    toIntervalQuarter(1) AS interval_to_quarter
SELECT date + interval_to_quarter AS result
```

```response title=Response theme={null}
┌─────result─┐
│ 2025-09-15 │
└────────────┘
```

<div id="toIntervalSecond">
  ## toIntervalSecond
</div>

v1.1.0에 도입되었습니다.

데이터 타입 [`IntervalSecond`](/ko/reference/data-types/special-data-types/interval)의 `n`초 인터벌을 반환합니다.

**구문**

```sql theme={null}
toIntervalSecond(n)
```

**인수**

* `n` — 초 단위 값입니다. 정수, 해당 정수의 문자열 표현 또는 부동소수점 수입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`String`](/ko/reference/data-types/string)

**반환 값**

`n`초의 인터벌을 반환합니다. [`Interval`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH
    toDate('2025-06-15') AS date,
    toIntervalSecond(30) AS interval_to_seconds
SELECT date + interval_to_seconds AS result
```

```response title=Response theme={null}
┌──────────────result─┐
│ 2025-06-15 00:00:30 │
└─────────────────────┘
```

<div id="toIntervalWeek">
  ## toIntervalWeek
</div>

도입 버전: v1.1.0

[`IntervalWeek`](/ko/reference/data-types/special-data-types/interval) 데이터 타입의 `n`주 인터벌을 반환합니다.

**구문**

```sql theme={null}
toIntervalWeek(n)
```

**인수**

* `n` — 주(week) 수입니다. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`String`](/ko/reference/data-types/string)

**반환 값**

`n`주를 나타내는 인터벌을 반환합니다. [`Interval`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH
    toDate('2025-06-15') AS date,
    toIntervalWeek(1) AS interval_to_week
SELECT date + interval_to_week AS result
```

```response title=Response theme={null}
┌─────result─┐
│ 2025-06-22 │
└────────────┘
```

<div id="toIntervalYear">
  ## toIntervalYear
</div>

도입 버전: v1.1.0

데이터 타입 [`IntervalYear`](/ko/reference/data-types/special-data-types/interval)의 `n`년 인터벌을 반환합니다.

**구문**

```sql theme={null}
toIntervalYear(n)
```

**인수**

* `n` — 년 수. [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float) 또는 [`String`](/ko/reference/data-types/string)

**반환 값**

`n`년을 나타내는 인터벌을 반환합니다. [`Interval`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH
    toDate('2024-06-15') AS date,
    toIntervalYear(1) AS interval_to_year
SELECT date + interval_to_year AS result
```

```response title=Response theme={null}
┌─────result─┐
│ 2025-06-15 │
└────────────┘
```

<div id="toLowCardinality">
  ## toLowCardinality
</div>

도입 버전: v18.12.0

입력 인수를 동일한 데이터 타입의 [LowCardinality](/ko/reference/data-types/lowcardinality) 버전으로 변환합니다.

<Tip>
  `LowCardinality` 데이터 타입을 일반 데이터 타입으로 변환하려면 [CAST](#CAST) 함수를 사용하십시오.
  예시: `CAST(x AS String)`.
</Tip>

**구문**

```sql theme={null}
toLowCardinality(expr)
```

**인수**

* `expr` — 지원되는 데이터 타입 중 하나의 값을 생성하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring) 또는 [`Date`](/ko/reference/data-types/date) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)

**반환 값**

입력 값을 `LowCardinality` 데이터 타입으로 변환한 값을 반환합니다. [`LowCardinality`](/ko/reference/data-types/lowcardinality)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toLowCardinality('1')
```

```response title=Response theme={null}
┌─toLowCardinality('1')─┐
│ 1                     │
└───────────────────────┘
```

<div id="toString">
  ## toString
</div>

도입 버전: v1.1.0

값을 문자열 표현으로 변환합니다.
DateTime 인수의 경우, 시간대 이름이 포함된 두 번째 String 인수를 받을 수 있습니다.

**구문**

```sql theme={null}
toString(value[, timezone])
```

**인수**

* `value` — 문자열 표현으로 변환할 값입니다. [`Any`](/ko/reference/data-types/index)
* `timezone` — 선택 사항입니다. DateTime 변환에 사용할 시간대 이름입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

입력 값의 문자열 표현을 반환합니다. [`String`](/ko/reference/data-types/string)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    now() AS ts,
    time_zone,
    toString(ts, time_zone) AS str_tz_datetime
FROM system.time_zones
WHERE time_zone LIKE 'Europe%'
LIMIT 10
```

```response title=Response theme={null}
┌──────────────────ts─┬─time_zone─────────┬─str_tz_datetime─────┐
│ 2023-09-08 19:14:59 │ Europe/Amsterdam  │ 2023-09-08 21:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Andorra    │ 2023-09-08 21:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Astrakhan  │ 2023-09-08 23:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Athens     │ 2023-09-08 22:14:59 │
│ 2023-09-08 19:14:59 │ Europe/Belfast    │ 2023-09-08 20:14:59 │
└─────────────────────┴───────────────────┴─────────────────────┘
```

<div id="toStringCutToZero">
  ## toStringCutToZero
</div>

도입 버전: v1.1.0

[String](/ko/reference/data-types/string) 또는 [FixedString](/ko/reference/data-types/fixedstring) 인수를 받아, 원본 문자열을 첫 번째 널 바이트(null byte)에서 잘라낸 복사본을 담은 String을 반환합니다.

널 바이트(\0)는 문자열 종료자로 간주됩니다.
이 함수는 널 바이트가 의미 있는 콘텐츠의 끝을 나타내는 C 스타일 문자열이나 이진 데이터를 처리할 때 유용합니다.

**구문**

```sql theme={null}
toStringCutToZero(s)
```

**인수**

* `s` — 처리할 `String` 또는 `FixedString`입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

첫 번째 null byte 앞까지의 문자를 포함하는 `String`을 반환합니다. [`String`](/ko/reference/data-types/string)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toStringCutToZero('hello'),
    toStringCutToZero('hello\0world')
```

```response title=Response theme={null}
┌─toStringCutToZero('hello')─┬─toStringCutToZero('hello\\0world')─┐
│ hello                      │ hello                             │
└────────────────────────────┴───────────────────────────────────┘
```

<div id="toTime">
  ## toTime
</div>

도입 버전: v1.1.0

입력 값을 [Time](/ko/reference/data-types/time) 유형으로 변환합니다.
String, FixedString, DateTime 또는 자정 이후 경과한 초를 나타내는 숫자 타입에서 변환할 수 있습니다.

**구문**

```sql theme={null}
toTime(x)
```

**인수**

* `x` — 변환할 입력 값입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring) 또는 [`DateTime`](/ko/reference/data-types/datetime) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)

**반환 값**

변환된 값을 반환합니다. [`Time`](/ko/reference/data-types/time)

**예시**

**String을 Time으로 변환**

```sql title=Query theme={null}
SELECT toTime('14:30:25')
```

```response title=Response theme={null}
14:30:25
```

**DateTime을 Time으로 변환**

```sql title=Query theme={null}
SELECT toTime(toDateTime('2025-04-15 14:30:25'))
```

```response title=Response theme={null}
14:30:25
```

**정수를 Time으로 변환**

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

```response title=Response theme={null}
14:30:25
```

<div id="toTime64">
  ## toTime64
</div>

도입 버전: v25.6.0

입력 값을 [Time64](/ko/reference/data-types/time64) 타입으로 변환합니다.
String, FixedString, DateTime64 또는 자정 이후 경과한 마이크로초를 나타내는 숫자 타입에서 변환할 수 있습니다.
시간 값에 마이크로초 정밀도를 제공합니다.

**구문**

```sql theme={null}
toTime64(x)
```

**인수**

* `x` — 변환할 입력 값입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring) 또는 [`DateTime64`](/ko/reference/data-types/datetime64) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)

**반환 값**

마이크로초 정밀도의 변환된 입력 값을 반환합니다. [`Time64(6)`](/ko/reference/data-types/time64)

**예시**

**String에서 Time64로 변환**

```sql title=Query theme={null}
SELECT toTime64('14:30:25.123456')
```

```response title=Response theme={null}
14:30:25.123456
```

**DateTime64에서 Time64로 변환**

```sql title=Query theme={null}
SELECT toTime64(toDateTime64('2025-04-15 14:30:25.123456', 6))
```

```response title=Response theme={null}
14:30:25.123456
```

**정수를 Time64로 변환하기**

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

```response title=Response theme={null}
14:30:25.123456
```

<div id="toTime64OrNull">
  ## toTime64OrNull
</div>

도입 버전: v25.6.0

입력 값을 `Time64` 타입의 값으로 변환하며, 오류가 발생하면 `NULL`을 반환합니다.
[`toTime64`](#toTime64)와 동일하지만, 변환 오류 시 예외를 발생시키는 대신 `NULL`을 반환합니다.

관련 항목:

* [`toTime64`](#toTime64)
* [`toTime64OrZero`](#toTime64OrZero)

**구문**

```sql theme={null}
toTime64OrNull(x)
```

**인수**

* `x` — 초 미만 정밀도를 포함하는 시간의 문자열 표현입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 `Time64` 값을 반환하고, 그렇지 않으면 `NULL`을 반환합니다. [`Time64`](/ko/reference/data-types/time64) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toTime64OrNull('12:30:45.123'), toTime64OrNull('invalid')
```

```response title=Response theme={null}
┌─toTime64OrNull('12:30:45.123')─┬─toTime64OrNull('invalid')─┐
│                   12:30:45.123 │                      ᴺᵁᴸᴸ │
└────────────────────────────────┴───────────────────────────┘
```

<div id="toTime64OrZero">
  ## toTime64OrZero
</div>

도입 버전: v25.6.0

입력 값을 Time64 유형의 값으로 변환하며, 오류가 발생하면 `00:00:00.000`을 반환합니다.
[`toTime64`](#toTime64)와 비슷하지만, 변환 오류 시 예외를 발생시키는 대신 `00:00:00.000`을 반환합니다.

**구문**

```sql theme={null}
toTime64OrZero(x)
```

**인수**

* `x` — 초 미만 정밀도를 포함한 시간의 문자열 표현입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 Time64 값을 반환하며, 그렇지 않으면 `00:00:00.000`을 반환합니다. [`Time64`](/ko/reference/data-types/time64)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toTime64OrZero('12:30:45.123'), toTime64OrZero('invalid')
```

```response title=Response theme={null}
┌─toTime64OrZero('12:30:45.123')─┬─toTime64OrZero('invalid')─┐
│                   12:30:45.123 │             00:00:00.000 │
└────────────────────────────────┴──────────────────────────┘
```

<div id="toTimeOrNull">
  ## toTimeOrNull
</div>

도입 버전: v1.1.0

입력값을 Time 유형의 값으로 변환하며, 오류가 발생한 경우 `NULL`을 반환합니다.
[`toTime`](#toTime)과 비슷하지만, 변환 오류 시 예외를 발생시키는 대신 `NULL`을 반환합니다.

관련 항목:

* [`toTime`](#toTime)
* [`toTimeOrZero`](#toTimeOrZero)

**구문**

```sql theme={null}
toTimeOrNull(x)
```

**인수**

* `x` — 시간을 나타내는 문자열입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 Time 값을 반환하고, 그렇지 않으면 `NULL`을 반환합니다. [`Time`](/ko/reference/data-types/time) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toTimeOrNull('12:30:45'), toTimeOrNull('invalid')
```

```response title=Response theme={null}
┌─toTimeOrNull('12:30:45')─┬─toTimeOrNull('invalid')─┐
│                 12:30:45 │                    ᴺᵁᴸᴸ │
└──────────────────────────┴─────────────────────────┘
```

<div id="toTimeOrZero">
  ## toTimeOrZero
</div>

도입 버전: v1.1.0

입력 값을 Time 타입의 값으로 변환하며, 오류가 발생하면 `00:00:00`을 반환합니다.
toTime과 같지만, 변환 오류 시 예외를 발생시키는 대신 `00:00:00`을 반환합니다.

**구문**

```sql theme={null}
toTimeOrZero(x)
```

**인수**

* `x` — 시간을 문자열로 나타낸 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 `Time` 값을 반환하며, 그렇지 않으면 `00:00:00`을 반환합니다. [`Time`](/ko/reference/data-types/time)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toTimeOrZero('12:30:45'), toTimeOrZero('invalid')
```

```response title=Response theme={null}
┌─toTimeOrZero('12:30:45')─┬─toTimeOrZero('invalid')─┐
│                 12:30:45 │                00:00:00 │
└──────────────────────────┴─────────────────────────┘
```

<div id="toUInt128">
  ## toUInt128
</div>

도입 버전: v1.1.0

입력 값을 [`UInt128`](/ko/reference/functions/regular-functions/type-conversion-functions#toUInt128) 유형의 값으로 변환합니다.
오류가 발생하면 예외를 발생시킵니다.
이 함수는 0 쪽으로 반올림을 수행하므로 숫자의 소수 자릿수는 잘려 나갑니다.

지원되는 인수:

* (U)Int\* 유형의 값 또는 문자열 표현.
* Float\* 유형의 값.

지원되지 않는 인수:

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt128('0xc0fe');`.

<Note>
  입력 값을 UInt128의 범위 내에서 표현할 수 없으면 결과가 오버플로우 또는 언더플로우될 수 있습니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt128OrZero`](#toUInt128OrZero).
* [`toUInt128OrNull`](#toUInt128OrNull).
* [`toUInt128OrDefault`](#toUInt128OrDefault).

**구문**

```sql theme={null}
toUInt128(expr)
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

128비트 부호 없는 정수 값을 반환합니다. [`UInt128`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt128(128),
    toUInt128(128.8),
    toUInt128('128')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt128(128):   128
toUInt128(128.8): 128
toUInt128('128'): 128
```

<div id="toUInt128OrDefault">
  ## toUInt128OrDefault
</div>

도입 버전: v21.11.0

[`toUInt128`](#toUInt128)와 마찬가지로, 이 함수는 입력 값을 [`UInt128`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만 오류가 발생하면 기본값을 반환합니다.
`default` 값이 전달되지 않으면 오류가 발생할 때 `0`을 반환합니다.

**구문**

```sql theme={null}
toUInt128OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자를 나타내는 문자열 표현을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패하면 반환할 기본값입니다. [`UInt128`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 UInt128 타입의 값을 반환합니다. 실패하면 `default`가 전달된 경우 해당 기본값을 반환하고, 그렇지 않으면 0을 반환합니다. [`UInt128`](/ko/reference/data-types/int-uint)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toUInt128OrDefault('128', CAST('0', 'UInt128'))
```

```response title=Response theme={null}
128
```

**변환 실패**

```sql title=Query theme={null}
SELECT toUInt128OrDefault('abc', CAST('0', 'UInt128'))
```

```response title=Response theme={null}
0
```

<div id="toUInt128OrNull">
  ## toUInt128OrNull
</div>

지원 버전: v21.6.0

이 함수는 [`toUInt128`](#toUInt128)와 마찬가지로 입력 값을 [`UInt128`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생하면 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 표현.

지원되지 않는 인수(`NULL` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt128OrNull('0xc0fe');`.

<Note>
  입력 값을 [`UInt128`](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt128`](#toUInt128).
* [`toUInt128OrZero`](#toUInt128OrZero).
* [`toUInt128OrDefault`](#toUInt128OrDefault).

**구문**

```sql theme={null}
toUInt128OrNull(x)
```

**인수**

* `x` — 숫자를 나타내는 문자열입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`UInt128` 유형의 값을 반환하며, 변환에 실패하면 `NULL`을 반환합니다. [`UInt128`](/ko/reference/data-types/int-uint) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt128OrNull('128'),
    toUInt128OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt128OrNull('128'): 128
toUInt128OrNull('abc'): \N
```

<div id="toUInt128OrZero">
  ## toUInt128OrZero
</div>

도입 버전: v1.1.0

[`toUInt128`](#toUInt128)와 마찬가지로, 이 함수는 입력 값을 [`UInt128`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하며, 오류가 발생하면 `0`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 표현.

지원되지 않는 인수 (`0` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt128OrZero('0xc0fe');`.

<Note>
  입력 값을 [`UInt128`](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt128`](#toUInt128).
* [`toUInt128OrNull`](#toUInt128OrNull).
* [`toUInt128OrDefault`](#toUInt128OrDefault).

**구문**

```sql theme={null}
toUInt128OrZero(x)
```

**인수**

* `x` — 숫자를 문자열로 표현한 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`UInt128` 타입의 값을 반환합니다. 변환에 실패하면 `0`을 반환합니다. [`UInt128`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt128OrZero('128'),
    toUInt128OrZero('abc')
FORMAT Vertical
```

```response title=Response theme={null}
행 1:
──────
toUInt128OrZero('128'): 128
toUInt128OrZero('abc'): 0
```

<div id="toUInt16">
  ## toUInt16
</div>

도입 버전: v1.1.0

입력 값을 [`UInt16`](/ko/reference/data-types/int-uint) 타입의 값으로 변환합니다.
오류가 발생하면 예외를 발생시킵니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 해당 값의 문자열 표현.
* Float\* 타입의 값.

지원되지 않는 인수:

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt16('0xc0fe');`.

<Note>
  입력 값을 [`UInt16`](/ko/reference/data-types/int-uint) 범위로 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
  예: `SELECT toUInt16(65536) == 0;`.
</Note>

<Note>
  이 함수는 [0 쪽으로 반올림](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero) 방식을 사용하므로 숫자의 소수 자릿수를 버립니다.
</Note>

관련 항목:

* [`toUInt16OrZero`](#toUInt16OrZero).
* [`toUInt16OrNull`](#toUInt16OrNull).
* [`toUInt16OrDefault`](#toUInt16OrDefault).

**구문**

```sql theme={null}
toUInt16(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 나타내는 문자열을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

16비트 부호 없는 정수 값을 반환합니다. [`UInt16`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt16(16),
    toUInt16(16.16),
    toUInt16('16')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt16(16):    16
toUInt16(16.16): 16
toUInt16('16'):  16
```

<div id="toUInt16OrDefault">
  ## toUInt16OrDefault
</div>

도입 버전: v21.11.0

[`toUInt16`](#toUInt16)와 마찬가지로, 이 함수는 입력 값을 [UInt16](/ko/reference/data-types/int-uint) 타입으로 변환하지만 오류가 발생하면 기본값을 반환합니다.
`default` 값이 전달되지 않으면 오류가 발생할 때 `0`이 반환됩니다.

**구문**

```sql theme={null}
toUInt16OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패할 경우 반환할 기본값입니다. [`UInt16`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 UInt16 타입의 값을 반환합니다. 실패한 경우 `default`가 전달되면 해당 기본값을 반환하고, 그렇지 않으면 0을 반환합니다. [`UInt16`](/ko/reference/data-types/int-uint)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toUInt16OrDefault('16', CAST('0', 'UInt16'))
```

```response title=Response theme={null}
16
```

**변환 실패**

```sql title=Query theme={null}
SELECT toUInt16OrDefault('abc', CAST('0', 'UInt16'))
```

```response title=Response theme={null}
0
```

<div id="toUInt16OrNull">
  ## toUInt16OrNull
</div>

v1.1.0에 도입됨

[`toUInt16`](#toUInt16)와 마찬가지로, 이 함수는 입력값을 [`UInt16`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만 오류가 발생하면 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int8/16/32/128/256의 문자열 표현.

지원되지 않는 인수 (`NULL` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현(예: `SELECT toUInt16OrNull('0xc0fe');`).

<Note>
  입력값이 [`UInt16`](/ko/reference/data-types/int-uint)의 범위 내에서 표현될 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt16`](#toUInt16).
* [`toUInt16OrZero`](#toUInt16OrZero).
* [`toUInt16OrDefault`](#toUInt16OrDefault).

**구문**

```sql theme={null}
toUInt16OrNull(x)
```

**인수**

* `x` — 숫자의 문자열 표현입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`UInt16` 타입의 값을 반환하고, 변환에 실패하면 `NULL`을 반환합니다. [`UInt16`](/ko/reference/data-types/int-uint) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt16OrNull('16'),
    toUInt16OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt16OrNull('16'):  16
toUInt16OrNull('abc'): \N
```

<div id="toUInt16OrZero">
  ## toUInt16OrZero
</div>

도입 버전: v1.1.0

[`toUInt16`](#toUInt16)와 마찬가지로, 이 함수는 입력 값을 [`UInt16`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생한 경우 `0`을 반환합니다.

지원되는 인수:

* (U)Int8/16/32/128/256의 문자열 표현.

지원되지 않는 인수(`0` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt16OrZero('0xc0fe');`.

<Note>
  입력 값을 [`UInt16`](/ko/reference/data-types/int-uint)의 범위 안에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt16`](#toUInt16).
* [`toUInt16OrNull`](#toUInt16OrNull).
* [`toUInt16OrDefault`](#toUInt16OrDefault).

**구문**

```sql theme={null}
toUInt16OrZero(x)
```

**인수**

* `x` — 숫자를 나타내는 String입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

UInt16 타입의 값을 반환하며, 변환에 실패하면 `0`을 반환합니다. [`UInt16`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt16OrZero('16'),
    toUInt16OrZero('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt16OrZero('16'):  16
toUInt16OrZero('abc'): 0
```

<div id="toUInt256">
  ## toUInt256
</div>

도입 버전: v1.1.0

입력 값을 UInt256 타입의 값으로 변환합니다.
오류 시 예외가 발생합니다.
이 함수는 0 방향으로 반올림하므로 숫자의 소수 자릿수는 버려집니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 문자열 표현.
* Float\* 타입의 값.

지원되지 않는 인수:

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현(예: `SELECT toUInt256('0xc0fe');`).

<Note>
  입력 값을 UInt256 범위 내에서 표현할 수 없으면 결과에서 오버플로 또는 언더플로가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt256OrZero`](#toUInt256OrZero).
* [`toUInt256OrNull`](#toUInt256OrNull).
* [`toUInt256OrDefault`](#toUInt256OrDefault).

**구문**

```sql theme={null}
toUInt256(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 나타낸 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

256비트 부호 없는 정수 값을 반환합니다. [`UInt256`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt256(256),
    toUInt256(256.256),
    toUInt256('256')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt256(256):     256
toUInt256(256.256): 256
toUInt256('256'):   256
```

<div id="toUInt256OrDefault">
  ## toUInt256OrDefault
</div>

도입 버전: v21.11.0

이 함수는 [`toUInt256`](#toUInt256)와 마찬가지로 입력값을 [UInt256](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생하면 기본값을 반환합니다.
`default` 값이 전달되지 않으면 오류가 발생한 경우 `0`을 반환합니다.

**구문**

```sql theme={null}
toUInt256OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자를 나타내는 문자열을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패한 경우 반환할 기본값입니다. [`UInt256`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 UInt256 타입의 값을 반환합니다. 실패하면 `default`가 전달된 경우 해당 기본값을 반환하고, 그렇지 않으면 0을 반환합니다. [`UInt256`](/ko/reference/data-types/int-uint)

**예시**

**성공적으로 변환된 경우**

```sql title=Query theme={null}
SELECT toUInt256OrDefault('-256', CAST('0', 'UInt256'))
```

```response title=Response theme={null}
0
```

**변환 실패 시**

```sql title=Query theme={null}
SELECT toUInt256OrDefault('abc', CAST('0', 'UInt256'))
```

```response title=Response theme={null}
0
```

<div id="toUInt256OrNull">
  ## toUInt256OrNull
</div>

도입 버전: v20.8.0

[`toUInt256`](#toUInt256)와 마찬가지로, 이 함수는 입력 값을 [`UInt256`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생하면 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 표현.

지원되지 않는 인수 (`NULL` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt256OrNull('0xc0fe');`.

<Note>
  입력 값을 [`UInt256`](/ko/reference/data-types/int-uint)의 범위 내 값으로 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt256`](#toUInt256).
* [`toUInt256OrZero`](#toUInt256OrZero).
* [`toUInt256OrDefault`](#toUInt256OrDefault).

**구문**

```sql theme={null}
toUInt256OrNull(x)
```

**인수**

* `x` — 숫자의 String 형식 표현입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`UInt256` 타입의 값을 반환합니다. 변환에 실패하면 `NULL`을 반환합니다. [`UInt256`](/ko/reference/data-types/int-uint) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt256OrNull('256'),
    toUInt256OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt256OrNull('256'): 256
toUInt256OrNull('abc'): \N
```

<div id="toUInt256OrZero">
  ## toUInt256OrZero
</div>

도입 버전: v20.8.0

[`toUInt256`](#toUInt256)와 마찬가지로, 이 함수는 입력 값을 [`UInt256`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생하는 경우 `0`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 표현입니다.

지원되지 않는 인수 (`0` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현입니다.
* 2진수 및 16진수 값의 문자열 표현입니다. 예: `SELECT toUInt256OrZero('0xc0fe');`.

<Note>
  입력 값을 [`UInt256`](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없는 경우 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt256`](#toUInt256).
* [`toUInt256OrNull`](#toUInt256OrNull).
* [`toUInt256OrDefault`](#toUInt256OrDefault).

**구문**

```sql theme={null}
toUInt256OrZero(x)
```

**인수**

* `x` — 숫자를 나타내는 문자열입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

UInt256 타입의 값을 반환하며, 변환에 실패하면 `0`을 반환합니다. [`UInt256`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt256OrZero('256'),
    toUInt256OrZero('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt256OrZero('256'): 256
toUInt256OrZero('abc'): 0
```

<div id="toUInt32">
  ## toUInt32
</div>

v1.1.0에서 도입되었습니다.

입력값을 [`UInt32`](/ko/reference/data-types/int-uint) 타입의 값으로 변환합니다.
오류가 발생하면 예외를 발생시킵니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 해당 값의 문자열 표현
* Float\* 타입의 값

지원되지 않는 인수:

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현
* 2진수 및 16진수 값의 문자열 표현(예: `SELECT toUInt32('0xc0fe');`)

<Note>
  입력값을 [`UInt32`](/ko/reference/data-types/int-uint) 범위 내에서 표현할 수 없으면 결과가 오버플로 또는 언더플로될 수 있습니다.
  이는 오류로 간주되지 않습니다.
  예: `SELECT toUInt32(4294967296) == 0;`
</Note>

<Note>
  이 함수는 [0 방향으로 반올림](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero)를 사용하므로 숫자의 소수 자릿수는 버려집니다.
</Note>

관련 항목:

* [`toUInt32OrZero`](#toUInt32OrZero).
* [`toUInt32OrNull`](#toUInt32OrNull).
* [`toUInt32OrDefault`](#toUInt32OrDefault).

**구문**

```sql theme={null}
toUInt32(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 표현한 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

32비트 부호 없는 정수 값을 반환합니다. [`UInt32`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt32(32),
    toUInt32(32.32),
    toUInt32('32')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt32(32):    32
toUInt32(32.32): 32
toUInt32('32'):  32
```

<div id="toUInt32OrDefault">
  ## toUInt32OrDefault
</div>

도입 버전: v21.11.0

이 함수는 [`toUInt32`](#toUInt32)와 마찬가지로 입력 값을 [UInt32](/ko/reference/data-types/int-uint) 유형의 값으로 변환하지만, 오류가 발생하면 기본값을 반환합니다.
`default` 값이 전달되지 않으면 오류 발생 시 `0`을 반환합니다.

**구문**

```sql theme={null}
toUInt32OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패할 경우 반환할 기본값입니다. [`UInt32`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 UInt32 타입의 값을 반환합니다. 실패하면 `default`가 전달된 경우 해당 기본값을 반환하고, 그렇지 않으면 0을 반환합니다. [`UInt32`](/ko/reference/data-types/int-uint)

**예시**

**성공적인 변환**

```sql title=Query theme={null}
SELECT toUInt32OrDefault('32', CAST('0', 'UInt32'))
```

```response title=Response theme={null}
32
```

**변환 실패**

```sql title=Query theme={null}
SELECT toUInt32OrDefault('abc', CAST('0', 'UInt32'))
```

```response title=Response theme={null}
0
```

<div id="toUInt32OrNull">
  ## toUInt32OrNull
</div>

도입 버전: v1.1.0

[`toUInt32`](#toUInt32)와 마찬가지로, 이 함수는 입력 값을 [`UInt32`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만 오류 시 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int8/16/32/128/256의 문자열 표현.

지원되지 않는 인수 (`NULL` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt32OrNull('0xc0fe');`.

<Note>
  입력 값을 [`UInt32`](/ko/reference/data-types/int-uint) 범위 내에 표현할 수 없는 경우, 결과에서 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt32`](#toUInt32).
* [`toUInt32OrZero`](#toUInt32OrZero).
* [`toUInt32OrDefault`](#toUInt32OrDefault).

**구문**

```sql theme={null}
toUInt32OrNull(x)
```

**인수**

* `x` — 숫자의 문자열 표현입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`UInt32` 타입의 값을 반환합니다. 변환에 실패하면 `NULL`을 반환합니다. [`UInt32`](/ko/reference/data-types/int-uint) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt32OrNull('32'),
    toUInt32OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt32OrNull('32'):  32
toUInt32OrNull('abc'): \N
```

<div id="toUInt32OrZero">
  ## toUInt32OrZero
</div>

도입 버전: v1.1.0

[`toUInt32`](#toUInt32)와 마찬가지로, 이 함수는 입력 값을 [`UInt32`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생하면 `0`을 반환합니다.

지원되는 인수:

* (U)Int8/16/32/128/256의 문자열 표현.

지원되지 않는 인수(`0` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt32OrZero('0xc0fe');`.

<Note>
  입력 값을 [`UInt32`](/ko/reference/data-types/int-uint) 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt32`](#toUInt32).
* [`toUInt32OrNull`](#toUInt32OrNull).
* [`toUInt32OrDefault`](#toUInt32OrDefault).

**구문**

```sql theme={null}
toUInt32OrZero(x)
```

**인수**

* `x` — 숫자의 문자열 표현입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`UInt32` 타입의 값을 반환하며, 변환에 실패하면 `0`을 반환합니다. [`UInt32`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt32OrZero('32'),
    toUInt32OrZero('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt32OrZero('32'):  32
toUInt32OrZero('abc'): 0
```

<div id="toUInt64">
  ## toUInt64
</div>

도입 버전: v1.1.0

입력값을 [`UInt64`](/ko/reference/data-types/int-uint) 타입의 값으로 변환합니다.
오류 시 예외가 발생합니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 해당 값의 문자열 표현.
* Float\* 타입의 값.

지원되지 않는 타입:

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt64('0xc0fe');`.

<Note>
  입력값을 [`UInt64`](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없으면 결과에 오버플로 또는 언더플로가 발생합니다.
  이는 오류로 간주되지 않습니다.
  예시: `SELECT toUInt64(18446744073709551616) == 0;`
</Note>

<Note>
  이 함수는 [0 방향으로 반올림](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero)를 사용하므로 숫자의 소수 자릿수를 버립니다.
</Note>

관련 항목:

* [`toUInt64OrZero`](#toUInt64OrZero).
* [`toUInt64OrNull`](#toUInt64OrNull).
* [`toUInt64OrDefault`](#toUInt64OrDefault).

**구문**

```sql theme={null}
toUInt64(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 나타낸 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

64비트 부호 없는 정수 값을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt64(64),
    toUInt64(64.64),
    toUInt64('64')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt64(64):    64
toUInt64(64.64): 64
toUInt64('64'):  64
```

<div id="toUInt64OrDefault">
  ## toUInt64OrDefault
</div>

도입 버전: v21.11.0

이 함수는 [`toUInt64`](#toUInt64)와 마찬가지로 입력 값을 [UInt64](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생하면 기본값을 반환합니다.
`default` 값이 전달되지 않으면 오류 발생 시 `0`을 반환합니다.

**구문**

```sql theme={null}
toUInt64OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 성공하지 못한 경우 반환할 기본값입니다. [`UInt64`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 UInt64 타입의 값을 반환하고, 실패하면 `default`가 전달된 경우 해당 기본값을, 그렇지 않으면 0을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**변환 성공**

```sql title=Query theme={null}
SELECT toUInt64OrDefault('64', CAST('0', 'UInt64'))
```

```response title=Response theme={null}
64
```

**변환 실패**

```sql title=Query theme={null}
SELECT toUInt64OrDefault('abc', CAST('0', 'UInt64'))
```

```response title=Response theme={null}
0
```

<div id="toUInt64OrNull">
  ## toUInt64OrNull
</div>

도입 버전: v1.1.0

[`toUInt64`](#toUInt64)와 마찬가지로, 이 함수는 입력 값을 [`UInt64`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생하면 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 형식.

지원되지 않는 인수(`NULL` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 형식.
* 이진수 및 16진수 값의 문자열 형식. 예: `SELECT toUInt64OrNull('0xc0fe');`.

<Note>
  입력 값을 [`UInt64`](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt64`](#toUInt64).
* [`toUInt64OrZero`](#toUInt64OrZero).
* [`toUInt64OrDefault`](#toUInt64OrDefault).

**구문**

```sql theme={null}
toUInt64OrNull(x)
```

**인수**

* `x` — 숫자를 나타내는 문자열입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`UInt64` 타입의 값을 반환합니다. 변환에 실패하면 `NULL`을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt64OrNull('64'),
    toUInt64OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt64OrNull('64'):  64
toUInt64OrNull('abc'): \N
```

<div id="toUInt64OrZero">
  ## toUInt64OrZero
</div>

도입 버전: v1.1.0

이 함수는 [`toUInt64`](#toUInt64)와 마찬가지로 입력값을 [`UInt64`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생하면 `0`을 반환합니다.

지원되는 인수:

* (U)Int\*의 문자열 표현.

지원되지 않는 인수(`0` 반환):

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt64OrZero('0xc0fe');`.

<Note>
  입력값을 [`UInt64`](/ko/reference/data-types/int-uint) 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt64`](#toUInt64).
* [`toUInt64OrNull`](#toUInt64OrNull).
* [`toUInt64OrDefault`](#toUInt64OrDefault).

**구문**

```sql theme={null}
toUInt64OrZero(x)
```

**인수**

* `x` — 숫자의 문자열 표현입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

`UInt64` 타입의 값을 반환합니다. 변환에 실패하면 `0`을 반환합니다. [`UInt64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt64OrZero('64'),
    toUInt64OrZero('abc')
FORMAT Vertical
```

```response title=Response theme={null}
행 1:
──────
toUInt64OrZero('64'):  64
toUInt64OrZero('abc'): 0
```

<div id="toUInt8">
  ## toUInt8
</div>

도입 버전: v1.1.0

입력값을 [`UInt8`](/ko/reference/data-types/int-uint) 타입의 값으로 변환합니다.
오류가 발생하면 예외가 발생합니다.

지원되는 인수:

* (U)Int\* 타입의 값 또는 해당 값의 문자열 표현.
* Float\* 타입의 값.

지원되지 않는 인수:

* `NaN` 및 `Inf`를 포함한 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt8('0xc0fe');`.

<Note>
  입력값을 [UInt8](/ko/reference/data-types/int-uint) 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
  예: `SELECT toUInt8(256) == 0;`.
</Note>

<Note>
  이 함수는 [0 방향으로 반올림](https://en.wikipedia.org/wiki/Rounding#Rounding_towards_zero)를 사용하므로 숫자의 소수 자릿수를 버립니다.
</Note>

관련 항목:

* [`toUInt8OrZero`](#toUInt8OrZero).
* [`toUInt8OrNull`](#toUInt8OrNull).
* [`toUInt8OrDefault`](#toUInt8OrDefault).

**구문**

```sql theme={null}
toUInt8(expr)
```

**인수**

* `expr` — 숫자 또는 숫자를 문자열로 나타낸 값을 반환하는 표현식입니다. [`표현식`](/ko/reference/data-types/special-data-types/expression)

**반환 값**

8비트 부호 없는 정수 값을 반환합니다. [`UInt8`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt8(8),
    toUInt8(8.8),
    toUInt8('8')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt8(8):   8
toUInt8(8.8): 8
toUInt8('8'): 8
```

<div id="toUInt8OrDefault">
  ## toUInt8OrDefault
</div>

도입 버전: v21.11.0

[`toUInt8`](#toUInt8)와 마찬가지로, 이 함수는 입력 값을 [UInt8](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만 오류가 발생하면 기본값을 반환합니다.
`default` 값이 전달되지 않으면 오류 발생 시 `0`을 반환합니다.

**구문**

```sql theme={null}
toUInt8OrDefault(expr[, default])
```

**인수**

* `expr` — 숫자 또는 숫자의 문자열 표현을 반환하는 표현식입니다. [`String`](/ko/reference/data-types/string) 또는 [`(U)Int*`](/ko/reference/data-types/int-uint) 또는 [`Float*`](/ko/reference/data-types/float)
* `default` — 선택 사항입니다. 파싱에 실패할 경우 반환할 기본값입니다. [`UInt8`](/ko/reference/data-types/int-uint)

**반환 값**

성공하면 `UInt8` 타입의 값을 반환하고, 실패하면 전달된 기본값을 반환하며, 기본값이 없으면 `0`을 반환합니다. [`UInt8`](/ko/reference/data-types/int-uint)

**예시**

**성공적으로 변환된 경우**

```sql title=Query theme={null}
SELECT toUInt8OrDefault('8', CAST('0', 'UInt8'))
```

```response title=Response theme={null}
8
```

**변환 실패**

```sql title=Query theme={null}
SELECT toUInt8OrDefault('abc', CAST('0', 'UInt8'))
```

```response title=Response theme={null}
0
```

<div id="toUInt8OrNull">
  ## toUInt8OrNull
</div>

도입 버전: v1.1.0

이 함수는 [`toUInt8`](#toUInt8)와 마찬가지로 입력 값을 [`UInt8`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생하면 `NULL`을 반환합니다.

지원되는 인수:

* (U)Int8/16/32/128/256의 문자열 표현.

지원되지 않는 인수(`NULL` 반환):

* `NaN` 및 `Inf`를 포함한 일반 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt8OrNull('0xc0fe');`.

<Note>
  입력 값을 [`UInt8`](/ko/reference/data-types/int-uint) 범위 내에서 표현할 수 없으면 결과에 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt8`](#toUInt8).
* [`toUInt8OrZero`](#toUInt8OrZero).
* [`toUInt8OrDefault`](#toUInt8OrDefault).

**구문**

```sql theme={null}
toUInt8OrNull(x)
```

**인수**

* `x` — 숫자를 나타내는 문자열 표현입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

UInt8 타입의 값을 반환하며, 변환에 실패하면 `NULL`을 반환합니다. [`UInt8`](/ko/reference/data-types/int-uint) 또는 [`NULL`](/ko/reference/syntax#null)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt8OrNull('42'),
    toUInt8OrNull('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt8OrNull('42'):  42
toUInt8OrNull('abc'): \N
```

<div id="toUInt8OrZero">
  ## toUInt8OrZero
</div>

도입 버전: v1.1.0

이 함수는 [`toUInt8`](#toUInt8)와 마찬가지로 입력 값을 [`UInt8`](/ko/reference/data-types/int-uint) 타입의 값으로 변환하지만, 오류가 발생한 경우에는 `0`을 반환합니다.

지원되는 인수:

* (U)Int8/16/32/128/256의 문자열 표현.

지원되지 않는 인수 (`0` 반환):

* `NaN` 및 `Inf`를 포함한 일반 Float\* 값의 문자열 표현.
* 2진수 및 16진수 값의 문자열 표현. 예: `SELECT toUInt8OrZero('0xc0fe');`.

<Note>
  입력 값을 [`UInt8`](/ko/reference/data-types/int-uint)의 범위 내에서 표현할 수 없으면 결과에서 오버플로우 또는 언더플로우가 발생합니다.
  이는 오류로 간주되지 않습니다.
</Note>

관련 항목:

* [`toUInt8`](#toUInt8).
* [`toUInt8OrNull`](#toUInt8OrNull).
* [`toUInt8OrDefault`](#toUInt8OrDefault).

**구문**

```sql theme={null}
toUInt8OrZero(x)
```

**인수**

* `x` — 숫자의 문자열 표현입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

UInt8 타입의 값을 반환합니다. 변환에 실패하면 `0`을 반환합니다. [`UInt8`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUInt8OrZero('-8'),
    toUInt8OrZero('abc')
FORMAT Vertical
```

```response title=Response theme={null}
Row 1:
──────
toUInt8OrZero('-8'):  0
toUInt8OrZero('abc'): 0
```

<div id="toUUID">
  ## toUUID
</div>

도입 버전: v1.1.0

String 값을 UUID로 변환합니다.

**구문**

```sql theme={null}
toUUID(string)
```

**인수**

* `string` — 문자열 형식의 UUID입니다. [`String`](/ko/reference/data-types/string) 또는 [`FixedString`](/ko/reference/data-types/fixedstring)

**반환 값**

UUID의 문자열 표현에서 UUID를 반환합니다. [`UUID`](/ko/reference/data-types/uuid)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT toUUID('61f0c404-5cb3-11e7-907b-a6006ad3dba0') AS uuid
```

```response title=Response theme={null}
┌─────────────────────────────────uuid─┐
│ 61f0c404-5cb3-11e7-907b-a6006ad3dba0 │
└──────────────────────────────────────┘
```

<div id="toUUIDOrZero">
  ## toUUIDOrZero
</div>

도입 버전: v20.12.0

입력 값을 [UUID](/ko/reference/data-types/uuid) 타입의 값으로 변환하지만, 오류가 발생하는 경우 0 UUID를 반환합니다.
[`toUUID`](/ko/reference/functions/regular-functions/type-conversion-functions#toUUID)와 유사하지만, 변환 오류 시 예외를 발생시키는 대신 0 UUID(`00000000-0000-0000-0000-000000000000`)를 반환합니다.

지원되는 인수:

* 표준 포맷(8-4-4-4-12개의 16진수 숫자)인 UUID의 문자열 표현
* 하이픈이 없는 UUID의 문자열 표현(32개의 16진수 숫자)

지원되지 않는 인수(0 UUID 반환):

* 잘못된 문자열 포맷
* 문자열이 아닌 타입

**구문**

```sql theme={null}
toUUIDOrZero(x)
```

**인수**

* `x` — UUID를 문자열로 표현한 값입니다. [`String`](/ko/reference/data-types/string)

**반환 값**

성공하면 UUID 값을 반환하고, 그렇지 않으면 0 UUID(`00000000-0000-0000-0000-000000000000`)를 반환합니다. [`UUID`](/ko/reference/data-types/uuid)

**예시**

**사용 예시**

```sql title=Query theme={null}
SELECT
    toUUIDOrZero('550e8400-e29b-41d4-a716-446655440000') AS valid_uuid,
    toUUIDOrZero('invalid-uuid') AS invalid_uuid
```

```response title=Response theme={null}
┌─valid_uuid───────────────────────────┬─invalid_uuid─────────────────────────┐
│ 550e8400-e29b-41d4-a716-446655440000 │ 00000000-0000-0000-0000-000000000000 │
└──────────────────────────────────────┴──────────────────────────────────────┘
```

<div id="toUnixTimestamp64Micro">
  ## toUnixTimestamp64Micro
</div>

도입 버전: v20.5.0

[`DateTime64`](/ko/reference/data-types/datetime64)를 고정된 마이크로초 정밀도의 [`Int64`](/ko/reference/data-types/int-uint) 값으로 변환합니다.
입력 값은 정밀도에 따라 적절히 확대되거나 축소됩니다.

<Note>
  출력 값은 입력 값의 시간대가 아니라 UTC를 기준으로 합니다.
</Note>

**구문**

```sql theme={null}
toUnixTimestamp64Micro(value)
```

**인수**

* `value` — 임의의 정밀도를 갖는 DateTime64 값입니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**반환 값**

마이크로초 단위의 Unix timestamp를 반환합니다. [`Int64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH toDateTime64('2025-02-13 23:31:31.011123', 6, 'UTC') AS dt64
SELECT toUnixTimestamp64Micro(dt64);
```

```response title=Response theme={null}
┌─toUnixTimestamp64Micro(dt64)─┐
│               1739489491011123 │
└────────────────────────────────┘
```

<div id="toUnixTimestamp64Milli">
  ## toUnixTimestamp64Milli
</div>

도입 버전: v20.5.0

[`DateTime64`](/ko/reference/data-types/datetime64)를 고정된 밀리초 정밀도를 가진 [`Int64`](/ko/reference/data-types/int-uint) 값으로 변환합니다.
입력 값은 정밀도에 따라 적절히 확대되거나 축소됩니다.

<Note>
  출력 값은 입력 값의 시간대가 아니라 UTC를 기준으로 합니다.
</Note>

**구문**

```sql theme={null}
toUnixTimestamp64Milli(value)
```

**인수**

* `value` — 임의의 정밀도를 지원하는 DateTime64 값입니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**반환 값**

밀리초 단위의 Unix timestamp를 반환합니다. [`Int64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH toDateTime64('2025-02-13 23:31:31.011', 3, 'UTC') AS dt64
SELECT toUnixTimestamp64Milli(dt64);
```

```response title=Response theme={null}
┌─toUnixTimestamp64Milli(dt64)─┐
│                1739489491011 │
└──────────────────────────────┘
```

<div id="toUnixTimestamp64Nano">
  ## toUnixTimestamp64Nano
</div>

도입 버전: v20.5.0

[`DateTime64`](/ko/reference/data-types/datetime64)를 고정된 나노초 정밀도의 [`Int64`](/ko/reference/functions/regular-functions/type-conversion-functions#toInt64) 값으로 변환합니다.
입력 값은 정밀도에 따라 적절히 확대되거나 축소됩니다.

<Note>
  출력 값은 입력 값의 시간대가 아니라 UTC를 기준으로 합니다.
</Note>

**구문**

```sql theme={null}
toUnixTimestamp64Nano(value)
```

**인수**

* `value` — 임의 정밀도의 DateTime64 값. [`DateTime64`](/ko/reference/data-types/datetime64)

**반환 값**

나노초 단위의 Unix timestamp를 반환합니다. [`Int64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH toDateTime64('2025-02-13 23:31:31.011123456', 9, 'UTC') AS dt64
SELECT toUnixTimestamp64Nano(dt64);
```

```response title=Response theme={null}
┌─toUnixTimestamp64Nano(dt64)────┐
│            1739489491011123456 │
└────────────────────────────────┘
```

<div id="toUnixTimestamp64Second">
  ## toUnixTimestamp64Second
</div>

도입 버전: v24.12.0

[`DateTime64`](/ko/reference/data-types/datetime64)를 초 단위의 고정 정밀도를 갖는 [`Int64`](/ko/reference/data-types/int-uint) 값으로 변환합니다.
입력 값은 정밀도에 따라 적절히 스케일업 또는 스케일다운됩니다.

<Note>
  출력 값은 입력 값의 시간대가 아니라 UTC를 기준으로 합니다.
</Note>

**구문**

```sql theme={null}
toUnixTimestamp64Second(value)
```

**인수**

* `value` — 임의의 정밀도를 갖는 DateTime64 값입니다. [`DateTime64`](/ko/reference/data-types/datetime64)

**반환 값**

초 단위 Unix timestamp를 반환합니다. [`Int64`](/ko/reference/data-types/int-uint)

**예시**

**사용 예시**

```sql title=Query theme={null}
WITH toDateTime64('2025-02-13 23:31:31.011', 3, 'UTC') AS dt64
SELECT toUnixTimestamp64Second(dt64);
```

```response title=Response theme={null}
┌─toUnixTimestamp64Second(dt64)─┐
│                    1739489491 │
└───────────────────────────────┘
```
