MySQL MINUTE() Function

The MINUTE() function is used to extract the minute part from a given time or datetime value.


Definition and Usage

  • Purpose: To extract the minute component of a time/datetime value.
  • Range: Returns a value between 0 and 59.

Syntax

MINUTE(datetime)

Parameter Values

Parameter Description
datetime Required. The time or datetime to extract the minute part from.

Technical Details

  • Introduced in: MySQL 4.0 and later.
  • Return Type: An integer value.

Examples

Example 1: Extracting Minutes from a Datetime

SELECT MINUTE("2017-06-20 09:34:00");

Result: 34

Example 2: Extracting Minutes from a Time

SELECT MINUTE("23:59:59");

Result: 59

Example 3: Using the Current Time

SELECT MINUTE(NOW());

Result: The current minute (depends on system time).

Example 4: Invalid Input

SELECT MINUTE("invalid-input");

Result: NULL
(Invalid datetime values return NULL.)


Key Notes

  1. The MINUTE() function works with both DATETIME and TIME values.
  2. If the input value is NULL or invalid, the function returns NULL.
  3. Useful for extracting and analyzing specific parts of a time or datetime, such as filtering records based on minute intervals.

Was this article helpful?