> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# date_time_* 格式设置

> ClickHouse 在 date_time_* 自动生成分组中的格式设置。

export const SettingsInfoBlock = ({type, default_value, changeable_without_restart}) => {
  return <div className="not-prose" style={{
    display: "flex",
    flexWrap: "wrap",
    alignItems: "baseline",
    columnGap: "0.5rem",
    rowGap: "0.125rem",
    margin: "0.375rem 0",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <div style={{
    fontWeight: 600,
    opacity: 0.72
  }}>类型</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>默认值</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          无需重启即可更改
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

这些设置由[源文件](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/FormatFactorySettings.h)自动生成。

<div id="date_time_64_output_format_cut_trailing_zeros_align_to_groups_of_thousands">
  ## date\_time\_64\_output\_format\_cut\_trailing\_zeros\_align\_to\_groups\_of\_thousands
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

动态去除 datetime64 值中末尾的零，将输出标度调整为 \[0, 3, 6]，
分别对应“秒”“毫秒”和“微秒”

<div id="date_time_input_format">
  ## date\_time\_input\_format
</div>

<SettingsInfoBlock type="DateTimeInputFormat" default_value="best_effort" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.5"},{"label": "best_effort"},{"label": "可用性更佳"}]}]} />

允许选择日期和时间文本表示的解析器。

此设置不适用于[日期和时间函数](/docs/zh/reference/functions/regular-functions/date-time-functions)。

可能的值：

* `'best_effort'` — 启用扩展解析。

  ClickHouse 可以解析基础的 `YYYY-MM-DD HH:MM:SS` 格式以及所有 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) 日期和时间格式。例如，`'2018-06-08T01:02:03.000Z'`。

* `'best_effort_us'` — 与 `best_effort` 类似 (差异请参见 [parseDateTimeBestEffortUS](/docs/zh/reference/functions/regular-functions/type-conversion-functions#parseDateTimeBestEffortUS))

* `'basic'` — 使用基础解析器。

  ClickHouse 只能解析基础的 `YYYY-MM-DD HH:MM:SS` 或 `YYYY-MM-DD` 格式。例如，`2019-08-20 10:18:56` 或 `2019-08-20`。

另请参见：

* [DateTime 数据类型。](/docs/zh/reference/data-types/datetime)
* [处理日期和时间的函数。](/docs/zh/reference/functions/regular-functions/date-time-functions)

<div id="date_time_output_format">
  ## date\_time\_output\_format
</div>

<SettingsInfoBlock type="DateTimeOutputFormat" default_value="simple" />

允许为日期和时间的文本表示选择不同的输出格式。

可能的值：

* `simple` - 简单输出格式。

  ClickHouse 以 `YYYY-MM-DD hh:mm:ss` 格式输出日期和时间。例如：`2019-08-20 10:18:56`。其计算依据为数据类型的 time zone (如果存在) 或 server time zone。

* `iso` - ISO 输出格式。

  ClickHouse 以 [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) `YYYY-MM-DDThh:mm:ssZ` 格式输出日期和时间。例如：`2019-08-20T10:18:56Z`。请注意，输出为 UTC (`Z` 表示 UTC) 。

* `unix_timestamp` - Unix timestamp 输出格式。

  ClickHouse 以 [Unix timestamp](https://en.wikipedia.org/wiki/Unix_time) 格式输出日期和时间。例如：`1566285536`。

另请参见：

* [DateTime 数据类型。](/docs/zh/reference/data-types/datetime)
* [用于处理日期和时间的函数。](/docs/zh/reference/functions/regular-functions/date-time-functions)

<div id="date_time_overflow_behavior">
  ## date\_time\_overflow\_behavior
</div>

<SettingsInfoBlock type="DateTimeOverflowBehavior" default_value="ignore" />

定义将 [Date](/docs/zh/reference/data-types/date)、[Date32](/docs/zh/reference/data-types/date32)、[DateTime](/docs/zh/reference/data-types/datetime)、[DateTime64](/docs/zh/reference/data-types/datetime64) 或整数转换为 Date、Date32、DateTime 或 DateTime64 时，如果该值无法用结果类型表示，系统应采取的行为。

可能的值：

* `ignore` — 静默忽略溢出。结果未定义。
* `throw` — 发生溢出时抛出异常。
* `saturate` — 将结果钳制到可表示范围内。如果该值小于目标类型可表示的最小值，则结果为最小可表示值；如果该值大于目标类型可表示的最大值，则结果为最大可表示值。

默认值：`ignore`。
