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