On this page本页内容
$dayOfYear
¶Returns the day of the year for a date as a number between 1 and 366.将日期的日期返回为1到366之间的数字。
The $dayOfYear
expression has the following operator expression syntax:$dayOfYear
表达式具有以下运算符表达式语法:
Changed in version 3.6.在版本3.6中更改。
The argument must be a valid expression that resolves to one of the following:参数必须是解析为以下之一的有效表达式:
New in version 3.6.版本3.6中的新功能。
date |
<dateExpression> | ||||||
timezone |
|
Result | |
---|---|
1 | |
7 | |
226 | |
311 | |
310 | |
error | |
error | |
error |
Note
$dayOfYear
cannot take a string as an argument.不能将字符串作为参数。
Consider a 考虑一个sales
collection with the following document:sales
集合带有以下文档:
The following aggregation uses the 以下聚合使用$dayOfYear
and other date expressions to break down the date
field:$dayOfYear
和其他日期表达式来分解date
字段:
The operation returns the following result:操作返回以下结果: