Extract the hour from the time value: HOUR()
mysql> mysql> mysql> SELECT HOUR('2004-12-31 23:59:59'); +-----------------------------+ | HOUR('2004-12-31 23:59:59') | +-----------------------------+ | 23 | +-----------------------------+ 1 row in set (0.00 sec)