MINUTE() Examples – MySQL

The MySQL MINUTE() function is used to return the minute component from a time value.

The return value for this function is in the range 0 to 59. Below are examples to demonstrate.

Syntax

The syntax of this function goes like this:

MINUTE(time)

Where time is the time value that you want to extract the minutes component from.

Example 1 – Basic Usage

Here’s an example to demonstrate.

SELECT MINUTE('10:35:27');

Result:

+--------------------+
| MINUTE('10:35:27') |
+--------------------+
|                 35 |
+--------------------+

Example 2 – Abbreviated Time Value

Here’s an example using an abbreviated time value, where only the hour and minutes are provided in the argument.

SELECT MINUTE('10:35');

Result:

+-----------------+
| MINUTE('10:35') |
+-----------------+
|              35 |
+-----------------+

However, be careful when using abbreviated time values, as MySQL can sometimes interpret them differently to what you might expect.

Here’s what the MySQL documentation says about this:

Be careful about assigning abbreviated values to a TIME column. MySQL interprets abbreviatedTIME values with colons as time of the day. That is, '11:12' means '11:12:00', not '00:11:12'. MySQL interprets abbreviated values without colons using the assumption that the two rightmost digits represent seconds (that is, as elapsed time rather than as time of day). For example, you might think of '1112' and 1112 as meaning '11:12:00' (12 minutes after 11 o’clock), but MySQL interprets them as '00:11:12' (11 minutes, 12 seconds). Similarly, '12' and 12 are interpreted as '00:00:12'.

Example 3 – An Alternative

You can also use the EXTRACT() function to extract the minutes (and other date/time parts) from a date/time value:

SELECT EXTRACT(MINUTE FROM '10:35:27');

Result:

+---------------------------------+
| EXTRACT(MINUTE FROM '10:35:27') |
+---------------------------------+
|                              35 |
+---------------------------------+