MySQL Hour function is one of the Date Functions, which returns the Hour from the given time. This MySQL Hour function returns ta value from 0 to 23. However, if the time is huge, the function return value greater than 23.
The syntax of the Hour Function is as shown below:
HOUR(Time or DateTime expression);
MySQL Hour function Example
These examples help you understand the use of hour function. Here, we are returning the hours from different times and a DateTime expression.
SELECT HOUR('2019-01-12 03:12:33');
Hour Function Example 2
The following MySQL queries show you what happens when we try to return the hours from string DateTime, invalid time, or 0 as the time value.
SELECT HOUR(NOW() + 15);