The $isoDayOfWeek operator extracts the weekday as an integer using the ISO 8601 calendar (Monday = 1 through Sunday = 7). Use it in aggregation pipelines to filter weekend orders, group sales by weekday, or label business vs non-business days.
01
ISO Weekday
Date → integer 1–7.
02
Syntax
One date argument.
03
Monday = 1
ISO 8601 numbering.
04
$project Stage
Add weekday fields.
05
Use Cases
Weekends, reporting.
06
vs $dayOfWeek
Different numbering.
Fundamentals
Definition and Usage
In MongoDB’s aggregation framework, the $isoDayOfWeek operator takes a date expression and returns an integer from 1 to 7 following the ISO 8601 standard. Monday = 1, Tuesday = 2, and Sunday = 7. For example, $isoDayOfWeek on ISODate("2024-06-17T00:00:00Z") (a Monday) returns 1.
ISO weekday numbering is common in business reporting, analytics dashboards, and international systems where the week starts on Monday. Pair $isoDayOfWeek with $isoWeek and $isoWeekYear for full ISO calendar analysis.
💡
Beginner Tip
Do not confuse $isoDayOfWeek with $dayOfWeek. MongoDB’s $dayOfWeek starts the week on Sunday (Sunday = 1). $isoDayOfWeek starts on Monday (Monday = 1). The same date can return different numbers.
Foundation
📝 Syntax
The $isoDayOfWeek operator takes a single date expression:
mongosh
{ $isoDayOfWeek: <dateExpression> }
Syntax Rules
Argument — any expression that evaluates to a BSON Date.
Return value — integer 1 (Monday) through 7 (Sunday) in UTC.
Null input — returns null when the date is null or missing.
Use inside $project, $addFields, $match with $expr, or $group.
ISO Weekday Number Reference
1 — Monday
2 — Tuesday
3 — Wednesday
4 — Thursday
5 — Friday
6 — Saturday
7 — Sunday
💡 $isoDayOfWeek vs $dayOfWeek
The same date can return different weekday numbers:
On Monday June 17, 2024: isoWeekday is 1 but mongoWeekday is 2. Always confirm which operator your reports and dashboards expect before building filters.
Applications
🚀 Use Cases
Weekend vs weekday analysis — filter or label orders, logins, or events by ISO business days.
Sales reporting — group revenue by weekday to spot Monday spikes or Friday dips.
Scheduling logic — route jobs or notifications differently on Saturdays and Sundays.
ISO calendar pipelines — combine with $isoWeek and $isoWeekYear for standard week-based reports.
🧠 How $isoDayOfWeek Works
1
MongoDB reads the date expression
The pipeline evaluates the input — a field like "$orderDate" or an ISODate literal.
Input
2
$isoDayOfWeek maps to ISO weekday
MongoDB converts the UTC calendar date to an integer 1–7 using ISO 8601 rules (Monday = 1, Sunday = 7).
Extract
3
The number is stored in the pipeline
The weekday integer is written to your output field or used as a $group key for aggregation.
Output
=
📅
ISO weekday data
You get standard weekday numbers ready for filtering, labeling, and grouped reports.
Wrap Up
Conclusion
The $isoDayOfWeek operator is the right choice when you need ISO 8601 weekday numbers in MongoDB aggregation pipelines. It starts the week on Monday and ends on Sunday, matching international business calendars and many analytics tools.
For beginners, the key idea is simple: wrap any date expression in { $isoDayOfWeek: ... } inside a stage like $project or $group. Remember the numbering differs from $dayOfWeek, and results are based on UTC unless you use timezone-aware alternatives.
Document which weekday operator your team uses in dashboards
Use $dateToParts when a specific timezone matters
❌ Don’t
Mix $isoDayOfWeek filters with $dayOfWeek numbering
Assume Monday = 1 for both ISO and MongoDB default operators
Forget that extraction uses UTC by default
Use on string dates without converting to BSON Date first
Confuse weekday extraction with $dayOfMonth (day of month)
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about $isoDayOfWeek
Use these points when working with ISO weekdays in MongoDB.
5
Core concepts
📅01
ISO Weekday
Monday=1, Sunday=7.
Purpose
📝02
Simple Syntax
{ $isoDayOfWeek: date }
Syntax
🛠03
Pipeline Stages
$project, $group, $match.
Usage
📈04
Weekend Filter
Values 6 and 7.
Pattern
⚠05
vs $dayOfWeek
Different numbering.
Important
❓ Frequently Asked Questions
$isoDayOfWeek returns an integer from 1 to 7 representing the ISO 8601 day of the week for a BSON Date. Monday is 1, Tuesday is 2, through Sunday which is 7.
The syntax is { $isoDayOfWeek: <dateExpression> }. Pass a field reference like "$orderDate", a literal ISODate, or another expression that evaluates to a date.
$isoDayOfWeek follows ISO 8601 (Monday=1, Sunday=7). $dayOfWeek uses MongoDB's default calendar (Sunday=1, Saturday=7). The same date can return different numbers.
$isoDayOfWeek extracts the weekday in UTC by default. For timezone-aware weekday extraction, use $dateToParts with a timezone option and read the isoDayOfWeek field.
$isoDayOfWeek returns null when the input date is null or refers to a missing field. It does not throw an error.