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

> Documentation for the Time64 data type in ClickHouse, which stores the time range with sub-second precision

# Time64

Data type `Time64` represents a time-of-day with fractional seconds.
It has no calendar date components (day, month, year).
The `precision` parameter defines the number of fractional digits and therefore the tick size.

Tick size (precision): 10<sup>-precision</sup> seconds. Valid range: 0..9. Common choices are 3 (milliseconds), 6 (microseconds), and 9 (nanoseconds).

**Syntax:**

```sql theme={null}
Time64(precision)
```

Internally, `Time64` stores a signed 64-bit decimal (Decimal64) number of fractional seconds.
The tick resolution is determined by the `precision` parameter.
Time zones are not supported: specifying a time zone with `Time64` will throw an error.

Unlike `DateTime64`, `Time64` does not store a date component.
See also [`Time`](/reference/data-types/time).

Text representation range: \[-999:59:59.000, 999:59:59.999] for `precision = 3`. In general, the minimum is `-999:59:59` and the maximum is `999:59:59` with up to `precision` fractional digits (for `precision = 9`, the minimum is `-999:59:59.999999999`).

<h2 id="implementation-details">
  Implementation details
</h2>

**Representation**.
Signed `Decimal64` value counting fractional second with `precision` fractional digits.

**Normalization**.
When parsing strings to `Time64`, the time components are normalized and not validated.
For example, `25:70:70` is interpreted as `26:11:10`.

**Negative values**.
Leading minus signs are supported and preserved.
Negative values typically arise from arithmetic operations on `Time64` values.
For `Time64`, negative inputs are preserved for both text (e.g., `'-01:02:03.123'`) and numeric inputs (e.g., `-3723.123`).

**Saturation**.
The time-of-day component is capped to the range \[-999:59:59.xxx, 999:59:59.xxx] when converting to components or serialising to text.
The stored numeric value may exceed this range; however, any component extraction (hours, minutes, seconds) and textual representation use the saturated value.

**Time zones**.
`Time64` does not support time zones.
Specifying a time zone when creating a `Time64` type or value throws an error.
Likewise, attempts to apply or change the time zone on `Time64` columns is not supported and results in an error.

<h2 id="examples">
  Examples
</h2>

1. Creating a table with a `Time64`-type column and inserting data into it:

```sql theme={null}
CREATE TABLE tab64
(
    `event_id` UInt8,
    `time` Time64(3)
)
ENGINE = TinyLog;
```

```sql theme={null}
-- Parse Time64
-- - from string,
-- - from a number of seconds since 00:00:00 (fractional part according to precision).
INSERT INTO tab64 VALUES (1, '14:30:25'), (2, 52225.123), (3, '14:30:25');

SELECT * FROM tab64 ORDER BY event_id;
```

```text theme={null}
   ┌─event_id─┬────────time─┐
1. │        1 │ 14:30:25.000 │
2. │        2 │ 14:30:25.123 │
3. │        3 │ 14:30:25.000 │
   └──────────┴──────────────┘
```

2. Filtering on `Time64` values

```sql theme={null}
SELECT * FROM tab64 WHERE time = toTime64('14:30:25', 3);
```

```text theme={null}
   ┌─event_id─┬────────time─┐
1. │        1 │ 14:30:25.000 │
2. │        3 │ 14:30:25.000 │
   └──────────┴──────────────┘
```

```sql theme={null}
SELECT * FROM tab64 WHERE time = toTime64(52225.123, 3);
```

```text theme={null}
   ┌─event_id─┬────────time─┐
1. │        2 │ 14:30:25.123 │
   └──────────┴──────────────┘
```

Note: `toTime64` parses numeric literals as seconds with a fractional part according to the specified precision, so provide the intended fractional digits explicitly.

3. Inspecting the resulting type:

```sql theme={null}
SELECT CAST('14:30:25.250' AS Time64(3)) AS column, toTypeName(column) AS type;
```

```text theme={null}
   ┌────────column─┬─type──────┐
1. │ 14:30:25.250 │ Time64(3) │
   └───────────────┴───────────┘
```

<h2 id="addition-with-date">
  Addition with Date
</h2>

A [Time64](/reference/data-types/time64) value can be added to a [Date](/reference/data-types/date) or [Date32](/reference/data-types/date32) value to produce a [DateTime64](/reference/data-types/datetime64) with the same scale as the `Time64`:

```sql theme={null}
SET use_legacy_to_time = 0;
SELECT toDate('2024-07-15') + toTime64('14:30:25.123456', 6) AS dt, toTypeName(dt);
```

```text theme={null}
   ┌─────────────────────────dt─┬─toTypeName(dt)─┐
1. │ 2024-07-15 14:30:25.123456 │ DateTime64(6)  │
   └────────────────────────────┴────────────────┘
```

See [Date and Time Addition](/reference/operators#date-time-addition) for details on all supported combinations and result types.

**See Also**

* [Type conversion functions](/reference/functions/regular-functions/type-conversion-functions)
* [Functions for working with dates and times](/reference/functions/regular-functions/date-time-functions)
* [The `date_time_input_format` setting](/reference/settings/formats#date_time_input_format)
* [The `date_time_output_format` setting](/reference/settings/formats#date_time_output_format)
* [The `timezone` server configuration parameter](/reference/settings/server-settings/settings#timezone)
* [The `session_timezone` setting](/reference/settings/session-settings#session_timezone)
* [Operators for working with dates and times](/reference/operators#operators-for-working-with-dates-and-times)
* [`Date` data type](/reference/data-types/date)
* [`Time` data type](/reference/data-types/time)
* [`DateTime` data type](/reference/data-types/datetime)
