HOUR()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns the hour for a TIME or DATETIME argument.
USAGE
HOUR(time)
Argument Name | Description |
|---|---|
| The time of day to measure |
DETAILS
HOUR() is date-time function that returns the hour of the time argument.
The date can be specifies as a data type that includes a time, a string, that can be parsed as a time-including data type (including hh:mm), or a hhmmss number.
The integer value returned is in the range 0 to 23.
A NULL is returned if the argument is NULL.
EXAMPLES
SELECT HOUR('01:00:10'), HOUR('00:53'), HOUR(123456);
+------------------+---------------+--------------+
| HOUR('01:00:10') | HOUR('00:53') | HOUR(123456) |
+------------------+---------------+--------------+
| 1 | 0 | 12 |
+------------------+---------------+--------------+
SELECT HOUR('2022-01-01 23:42:42 and such');
+--------------------------------------+
| HOUR('2022-01-01 23:42:42 and such') |
+--------------------------------------+
| 23 |
+--------------------------------------+
