The $minute operator extracts the minute portion (0–59) from a BSON Date inside MongoDB aggregation pipelines. Use it for scheduling analysis, cron-style patterns, per-minute dashboards, and time-slot reporting.
01
Extract Minute
Date → 0–59.
02
Syntax
One date argument.
03
Timezone Option
Local minute support.
04
UTC Default
0–59 in UTC.
05
Use Cases
Slots, cron jobs.
06
Related Ops
$hour, $second.
Fundamentals
Definition and Usage
In MongoDB’s aggregation framework, the $minute operator takes a date expression and returns an integer between 0 and 59. For example, $minute applied to ISODate("2024-06-15T14:30:45Z") returns 30, and ISODate("2024-06-15T09:05:00Z") returns 5.
Minutes sit between $hour and $second in MongoDB’s date-extraction family. Together they let you break any timestamp into readable parts for filtering, grouping, or display.
💡
Beginner Tip
$minute uses UTC by default. For appointment slots or business rules in local time, use the object form with a timezone option (see Example 4).
Foundation
📝 Syntax
The $minute operator takes a date expression, or an object with date and timezone:
Grouping by $minute aggregates all hours and days together — useful for spotting patterns like “most bookings happen at :00 or :30.” Pair with $hour if you need hour-and-minute combinations.
Example 4 — Minute in a Specific Timezone
Extract the minute in Eastern Time rather than UTC:
The object form with timezone converts the instant to the specified zone before extracting the minute. UTC and local values can differ when the local hour boundary does not align with UTC.
Bonus — Hour and Minute Time Slot
Build a readable time slot label from hour and minute:
Combine $hour and $minute with $concat and $cond to pad single-digit minutes. For 09:05 UTC, the slot label becomes "9:05".
Applications
🚀 Use Cases
Scheduling slots — group or filter appointments by minute within the hour.
Cron-style analysis — find jobs that run at :00, :15, :30, or :45.
Traffic patterns — discover which minute marks see the most activity.
Time-slot labels — combine with $hour for readable display values.
🧠 How $minute Works
1
MongoDB resolves the date
The input expression is evaluated per document — a field, $$NOW, or literal ISODate.
Input
2
$minute extracts the minute
MongoDB reads the minute component as an integer 0–59 (UTC or specified timezone).
Extract
3
An integer is returned
The number is ready for $match, $group, or time-slot logic.
Output
=
📅
Minute for scheduling analytics
Combine with $hour, $second, and $dateTrunc for richer time reporting.
Wrap Up
Conclusion
The $minute operator is a simple way to extract the minute component from BSON dates in MongoDB aggregation pipelines. It is especially useful for scheduling analysis, cron-style filters, and per-minute dashboards.
Remember it uses UTC by default and returns 0–59. For local business rules, pass a timezone in the object form. Next in the series: $mod.
Use $minute for minute-within-hour extraction (0–59)
Combine with $hour for full time-slot labels
Pass timezone when scheduling rules follow local time
Use $dateTrunc when you need minute-level buckets as Dates
Store dates as BSON Date type for reliable extraction
❌ Don’t
Confuse $minute with total minutes since midnight (compute that separately)
Use it on string dates without converting to Date first
Assume minute values carry hour context (they reset each hour)
Forget UTC default when comparing to local appointment times
Use $minute when $dateTrunc with unit: "minute" fits better
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about $minute
Use these points when working with minute-level date extraction in MongoDB.
5
Core concepts
🕑01
0–59 Range
Within the hour.
Purpose
📝02
One Date Arg
Field or ISODate.
Syntax
🛠03
UTC Default
Timezone optional.
Timezone
🔄04
Resets Each Hour
Not cumulative.
Edge case
📑05
Date Family
$hour, $second.
Related
❓ Frequently Asked Questions
$minute returns an integer from 0 to 59 representing the minute portion of a BSON Date. For example, 2:30 PM UTC returns 30, and 9:05 AM UTC returns 5.
Simple form: { $minute: <dateExpression> }. With timezone: { $minute: { date: <dateExpression>, timezone: <tz> } }. Pass a field like "$scheduledAt" or a literal ISODate.
By default, $minute uses UTC. To get the minute in a specific timezone, use the object form with a timezone string like "America/New_York".
$minute returns 0–59 (minute within the hour). $hour returns 0–23. $dateTrunc rounds a Date down to a period boundary — better for bucketing than extracting a single component.
$minute is available in MongoDB 3.4 and later in aggregation pipelines and update pipelines that use aggregation expressions.