- Reference >
- Operators >
- Aggregation Pipeline Operators >
- Date Aggregation Operators >
- $dayOfYear (aggregation)
$dayOfYear (aggregation)¶
On this page
Definition¶
-
$dayOfYear
¶ Returns the day of the year for a date as a number between 1 and 366.
The
$dayOfYear
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 $dayOfYear
and other date
expressions to break down the date
field:
The operation returns the following result: