MySQL Hour is one of the Date Functions, which returns the Hour from the given time. This Hour function returns the time value from 0 to 23. However, if the time is huge, this method returns a value greater than 23. The syntax of the Hour method is as shown below:
HOUR(Time or DateTime expression);
MySQL Hour function Example
These examples help you understand its use or its functionality of it. Here, we are returning the hours from different times and a DateTime expression.
SELECT HOUR('2019-01-12 03:12:33');
Let us see another example of the Hour Date method. Here, we are using NOW, UTC_TIME, and UTC_TIMESTAMP inside this method to get the Hour from the current date and time.
Hour Example 2
The following query shows you what happens when we try to return the hours from the string DateTime, invalid time, or 0 as the time value.
SELECT HOUR(NOW() + 15);