w3resource

MySQL MINUTE() function

MINUTE() function

MySQL MINUTE() returns a MINUTE from a time or datetime value. It provides a way to isolate the minute part of a time for various time-related calculations and analysis.

This function is useful in -

  • MINUTE() is valuable for analyzing time-based data, allowing you to focus on the minute part of a time.
  • MINUTE() aids in calculating time intervals, durations, and differences based on the minute component.
  • MINUTE() is useful for filtering data based on specific minutes of an hour, allowing focused analysis.
  • When working with datasets that include minute information, MINUTE() is used to perform calculations or transformations.
  • MINUTE() allows you to create custom time formats that include minute values.
  • In graphical or tabular representations, MINUTE() can be used to label axes or data points with minute values.
  • The function helps in scheduling tasks or events that need to occur at specific minutes past the hour.

Syntax:

MINUTE(time1);

Where time1 is time.

Syntax Diagram:

MySQL MINUTE() Function - Syntax Diagram

MySQL Version: 8.0


Pictorial Presentation:

Pictorial Presentation of MySQL MINUTE() function

Example: MySQL MINUTE() function

The above statement will return MINUTEs from the given datetime 2009-05-18 10:15:21.000423.

Code:

SELECT MINUTE('2009-05-18 10:15:21.000423');

Output:

mysql> SELECT MINUTE('2009-05-18 10:15:21.000423');
+--------------------------------------+
| MINUTE('2009-05-18 10:15:21.000423') |
+--------------------------------------+
|                                   15 | 
+--------------------------------------+
1 row in set (0.01 sec)

Example : MINUTE() function with current date

The following statement will return MINUTEs from the current time which is coming from the CURRENT_TIME(). The first column in the output shows the current time (for reference).

Code:

SELECT CURRENT_TIME(),MINUTE(CURRENT_TIME());

Note: Since CURRENT_TIME() is used, your output may vary from the output shown.

Output:

mysql> SELECT CURRENT_TIME(),MINUTE(CURRENT_TIME());
+----------------+------------------------+
| CURRENT_TIME() | MINUTE(CURRENT_TIME()) |
+----------------+------------------------+
| 18:04:03       |                      4 | 
+----------------+------------------------+
1 row in set (0.00 sec)

View the example in browser

Video Presentation:

All Date and Time Functions:

Click here to see the MySQL Date and time functions.

Previous: MICROSECOND()
Next: MONTH()



Follow us on Facebook and Twitter for latest update.