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

# to_iso8601

> 将日期转换为ISO 8601标准格式的字符串。

将某一个日期转换为 ISO 8601 标准格式的字符串。

## 语法

```Haskell theme={null}
VARCHAR TO_ISO8601(DATETIME | DATE date)
```

## 参数说明

`date`：待计算转换的日期，取值必须是合法的日期或日期表达式。

## 示例

示例一：将日期 `2020-01-01` 转换为 ISO 8601 标准格式的字符串。

```SQL theme={null}
MySQL > select to_iso8601(date'2020-01-01');
+--------------------------+
| to_iso8601('2020-01-01') |
+--------------------------+
| 2020-01-01               |
+--------------------------+
```

示例二：将日期 `2020-01-01 00:00:00.01` 转换为 ISO 8601 标准格式的字符串。

```SQL theme={null}
MySQL > select to_iso8601(datetime'2020-01-01 00:00:00.01');
+------------------------------------------+
| to_iso8601('2020-01-01 00:00:00.010000') |
+------------------------------------------+
| 2020-01-01T00:00:00.010000               |
+------------------------------------------+
```

## 关键字

TO\_ISO8601


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.