[DOCS-13862] Agg date expressions don't allow expressions to resolve to argument list Created: 02/Sep/20  Updated: 13/Nov/23  Resolved: 31/Jan/22

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: 4.2.0, 4.4.0, 5.0.0, 5.2.0, 5.3.0, Server_Docs_20231030, Server_Docs_20231106, Server_Docs_20231105, Server_Docs_20231113

Type: Bug Priority: Major - P3
Reporter: George Wangensteen Assignee: Jason Price
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 2 years, 1 week, 2 days ago
Epic Link: DOCSP-11701
Story Points: 3

 Description   

Description

Many agg date expressions, like $dayOfMonth, can take as argument either :
-An expression that resolves to a Date, Timestamp, or ObjectId
-A document that lists arguments with some particular syntax (like:

{date: X, timestamp: Y}

The docs currently say that these agg operators take just an expression, and then state: "The argument must be a valid expression that resolves to one of the following:
-A Date, a Timestamp, or an ObjectID.
-A document of the following form: ...."
However, they can't actually accept an expression that resolves to the document-of-arguments. The expression must resolve to either a Date, Timestamp, or ObjectID; the document-of-arguments can be provided instead of an expression.

For example:

MongoDB Enterprise > db.example.insert({a: { date: new Date("January 2, 1998") }})
WriteResult({ "nInserted" : 1 })
MongoDB Enterprise > db.example.find()
{ "_id" : ObjectId("5f4fed07a67c58f260e9a184"), "a" : { "date" : ISODate("1998-01-02T00:00:00Z") } }
 
MongoDB Enterprise > db.example.aggregate( [ { $project: { day: { $dayOfMonth: "$a" } } } ] )
uncaught exception: Error: command failed: {
	"ok" : 0,
	"errmsg" : "PlanExecutor error during aggregation :: caused by :: can't convert from BSON type object to Date",
	"code" : 16006,
	"codeName" : "Location16006"
} : aggregate failed :

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Githook User [ 31/Jan/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-13862 aggregation date expressions (#451) (#466)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: v4.2
https://github.com/10gen/docs-mongodb-internal/commit/1b422df4962abdd1c738eb28b9f982d3383f3c4b

Comment by Githook User [ 31/Jan/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-13862 aggregation date expressions (#451) (#465)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: v4.4
https://github.com/10gen/docs-mongodb-internal/commit/e6aceedb01f0d9592118c94f85686aaf676429bf

Comment by Githook User [ 31/Jan/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-13862 aggregation date expressions (#451) (#464)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: v5.0
https://github.com/10gen/docs-mongodb-internal/commit/76e0661bc857add3163dc818305d58bdf6573714

Comment by Githook User [ 31/Jan/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-13862 aggregation date expressions (#451) (#463)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: v5.2
https://github.com/10gen/docs-mongodb-internal/commit/28dda718879928e74630c0240cf74485493f9f73

Comment by Githook User [ 31/Jan/22 ]

Author:

{'name': 'jason-price-mongodb', 'email': '69260375+jason-price-mongodb@users.noreply.github.com', 'username': 'jason-price-mongodb'}

Message: DOCS-13862 aggregation date expressions (#451)

Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
Branch: master
https://github.com/10gen/docs-mongodb-internal/commit/0e01bd11b7cb56f3d8f6a53782ff02ccbd544238

Generated at Thu Feb 08 08:08:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.