- Reference >
- Operators >
- Aggregation Pipeline Operators >
- Date Aggregation Operators >
- $dayOfWeek (aggregation)
$dayOfWeek (aggregation)¶
On this page
Definition¶
-
$dayOfWeek
¶ Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday).
The
$dayOfWeek
expression has the following syntax:The argument can be any expression as long as it resolves to a date. For more information on expressions, see Expressions.
Example¶
Consider a sales
collection with the following document:
The following aggregation uses the $dayOfWeek
and other
date operators to break down the date
field:
The operation returns the following result: