db.Collection.aggregate(
[
{
$project:
{
yearMonth: { $month: "$Date" }
}
}
]
)
I would like to store the value of $month into the yearMonth field within my collection for all documents upon evaluation. The online documentation seems vague in how this is explained and online examples seem not to work. Can anyone please point me in the right direction?
I even tried the following to no avail:
db.Collection.update (
{ "$set": {"yearMonth": { $month: "$Date" }}},
{"multi": true}
)