MINUTE( )

This MySQL function returns the minute value (0-59) of a given time.

Syntax

Below is the syntax for this command. Text within square brackets (i.e, [ and ] ) are optional. Choices are separated by bars (i.e, | ). Ellipses preceded by a comma indicates a repeating pattern. Ellipses before or after syntax are used to highlight a relevant except from the larger syntax. Text displayed in italic letters represent text that should be replaced with the specific names related to the database (e.g., column with the name of the column).

MINUTE(time)

Explanation

This function returns the minute value (0-59) of a given time.

Examples

SELECT CONCAT(HOUR(appointment), ':',
MINUTE(appointment)) AS 'Appointment'
FROM appointments
WHERE client_id = '3992'
AND appointment > CURDATE( );

+-------------+
| Appointment |
+-------------+
|       13:30 |
+-------------+

This statement is using the string function CONCAT( ) to paste together the hour and the minute, with a colon as a separator. Of course, a function like DATE_FORMAT( ) would be a better choice for such a task. If an invalid time is given (e.g., minutes or seconds in excess of 59), NULL is returned and a warning issued.

SELECT MINUTE('13:60:00') AS 'Bad Time', 
MINUTE('13:30:00') AS 'Good Time';

+----------+-----------+
| Bad Time | Good Time |
+----------+-----------+
|     NULL |        30 | 
+----------+-----------+
1 row in set, 1 warning (0.00 sec)

SHOW WARNINGS;

+---------+------+--------------------------------------------+
| Level   | Code | Message                                    |
+---------+------+--------------------------------------------+
| Warning | 1292 | Truncated incorrect time value: '13:60:00' | 
+---------+------+--------------------------------------------+