HOUR()
HOUR(time)This function returns the hour for the time given. For
columns containing the time of day (e.g.,
DATETIME), the range of results will be from 0 to
23. For TIME data type columns that contain data
not restricted to day limits, this function may return values greater
than 23. Here is an example:
SELECT appt_id, appointment, HOUR(appointment) AS 'Hour of Appointment' FROM appointments WHERE client_id = '3992' AND appointment > CURDATE( ); +---------+---------------------+---------------------+ | appt_id | appointment | Hour of Appointment | +---------+---------------------+---------------------+ | 8393 | 2008-03-15 13:00:00 | 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.).