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

# hour

> 返回指定日期中的小时部分，取值范围 0 到 23。

获得指定日期中的小时信息。

## 语法

```Haskell theme={null}
INT HOUR(DATE|DATETIME date)
```

## 参数说明

`date`：必填。支持 DATETIME 和 DATE 类型。

## 返回值说明

返回 INT 类型的值，范围 0\~23。如果输入值类型为 DATE，则返回 0。
此函数会对整数和字符串类型的输入进行隐式转换，如果未能从输入中解析出合法小时信息，如 `hour('string')`，则返回 NULL。如果输入数据类型非法，如 `hour(3.1415)`，则返回报错。

## 示例

示例一：返回 '2018-12-31 23:59:59' 中的小时，`23`。

```Plain Text theme={null}
select hour('2018-12-31 23:59:59');
+-----------------------------+
| hour('2018-12-31 23:59:59') |
+-----------------------------+
|                          23 |
+-----------------------------+
```

示例二: 输入值为 DATE 类型，返回 `0`。

```Plain Text theme={null}
select hour('2018-12-31');
+--------------------+
| hour('2018-12-31') |
+--------------------+
|                  0 |
+--------------------+
1 row in set (0.00 sec)
```


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