Lesson

MySQL MINUTE() Function

10 min reading
Free Course

MySQL MINUTE() Function

The MySQL MINUTE() function returns the minute part of a TIME, DATETIME, or TIMESTAMP expression as an integer from 0 to 59.

Backend teams use MINUTE() to group traffic logs into hourly buckets, check SLA response windows, or build custom time-of-day filters. Unlike TIME_FORMAT(col, '%i'), which returns a zero-padded string like '05', MINUTE() returns a plain integer 5 ready for math comparisons.

MINUTE() ignores hours, seconds, and fractional seconds. It never rounds seconds upward, even when the time ends in .999999.

Syntax

MINUTE(time)
  • time: A TIME, DATETIME, or TIMESTAMP value, or a recognized time string or integer.

Practical Example

Consider the demo_orders table where created_at tracks exact order placement times. You can filter orders placed during the first 15 minutes of any hour for flash-sale analysis.

SELECT
    order_id,
    customer_id,
    created_at,
    MINUTE(created_at) AS order_minute
FROM demo_orders
WHERE HOUR(created_at) = 9
  AND MINUTE(created_at) < 15;
order_id customer_id created_at order_minute
201 18 2026-05-10 09:00:42 0
204 31 2026-05-10 09:07:19 7
209 44 2026-05-10 09:14:58 14

All three orders match because their minute component falls strictly below 15.

Common Mistakes & NULL Behavior

Passing a TIME duration larger than 24 hours still returns a 0 to 59 value. For example, MINUTE('120:45:10') returns 45. Do not expect MINUTE() to convert hours into total minutes; use TIME_TO_SEC(t) / 60 for total elapsed minutes.

Similarly, negative TIME values return a non-negative minute integer. MINUTE('-02:25:00') evaluates to 25, not -25.

If time is NULL or contains an invalid string such as '25:75:00' (minutes over 59), MINUTE() returns NULL. Avoid applying MINUTE() directly on indexed DATETIME columns inside WHERE clauses when querying large tables, because wrapping a column in a function prevents standard B-tree index range scans.

Frequently Asked Questions

Does MINUTE() round up when seconds are 59?

No. MINUTE('14:22:59') returns 22. It strictly extracts the minute component without rounding.

What does MINUTE() return for a DATE-only value?

A pure DATE value has no time component, so MySQL treats its time part as 00:00:00 and returns 0, or NULL if an unrecognized string fails TIME parsing.

Should I use MINUTE() or EXTRACT(MINUTE FROM col)?

Both return the same integer result in MySQL. MINUTE() is shorter, while EXTRACT(MINUTE FROM col) follows standard ANSI SQL syntax.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Try it Yourself

Experiment with the code from this lesson in our interactive playground.

Open Playground
MySQL Topic Hub

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum