Name
HOUR( )
Synopsis
HOUR(time
)
This function
returns the hour for the time given. For column types containing the
time of day (e.g., DATETIME
), the range of results
will be from 0 to 23. For TIME
datatype columns
that contain data not restricted to day limits, this function may
return values greater than 23.
SELECT HOUR(appointment) FROM appointments WHERE client_id = '3992' AND appointment > CURDATE( ); +-------------------+ | HOUR(appointment) | +-------------------+ | 13 | +-------------------+
This statement is selecting the upcoming appointment for a particular client. The hour is returned in military time (i.e., 13 is 1 p.m.).
Get MySQL in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.