HOUR
デスクリプション
指定されたdatetimeから時間情報を取得します。
Syntax
HOUR(<dt>)
パラメータ
| Parameter | デスクリプション |
|---|---|
<dt> | 計算対象の日付。 |
Return Value
指定された日付から時間情報を返します。戻り値の範囲は0から23です。パラメータがTIME型の場合、戻り値は24より大きくなる場合があります。
Examples
select hour('2018-12-31 23:59:59');
+-----------------------------+
| hour('2018-12-31 23:59:59') |
+-----------------------------+
| 23 |
+-----------------------------+
select cast(4562632 as time),hour(cast(4562632 as time)), minute(cast(4562632 as time)),second(cast(4562632 as time));
+-----------------------+-----------------------------+-------------------------------+-------------------------------+
| cast(4562632 as TIME) | hour(cast(4562632 as TIME)) | minute(cast(4562632 as TIME)) | second(cast(4562632 as TIME)) |
+-----------------------+-----------------------------+-------------------------------+-------------------------------+
| 456:26:32 | 456 | 26 | 32 |
+-----------------------+-----------------------------+-------------------------------+-------------------------------+