SQL Tutorial SQL Advanced SQL Database SQL References

MySQL MINUTE() Function



The MySQL MINUTE() function returns the minute portion of a given time or datetime value. It can be between 0 to 59.

Syntax

MINUTE(datetime)

Parameters

datetime Required. Specify a time or datetime value from which to extract the minute.

Return Value

Returns the minute part of a given time or datetime value.

Example 1:

The example below shows the usage of MINUTE() function.

mysql> SELECT MINUTE('2018-08-18');
Result: 0

mysql> SELECT MINUTE('2018-08-18 10:38:42');
Result: 38

mysql> SELECT MINUTE('2018-08-18 10:38:42.000004');
Result: 38

mysql> SELECT MINUTE("838:38:42");
Result: 38

mysql> SELECT MINUTE(CURDATE());
Result: 25

Example 2:

Consider a database table called Orders with the following records:

OrderQuantityPriceOrderTime
1001.582017-08-18 10:38:42
1201.612018-03-23 07:14:16
1251.782018-09-12 05:25:56
501.802019-01-16 11:52:05
2001.722020-02-06 09:31:34

The query given below can be used to get the minute portion of records of column OrderTime:

SELECT *, MINUTE(OrderTime) AS MINUTE_Value FROM Orders;

This will produce the result as shown below:

OrderQuantityPriceOrderTimeMINUTE_Value
1001.582017-08-18 10:38:4238
1201.612018-03-23 07:14:1614
1251.782018-09-12 05:25:5625
501.802019-01-16 11:52:0552
2001.722020-02-06 09:31:3431

❮ MySQL Functions

5