[DOCS-10404] Docs for SERVER-9406: Allow treating ObjectId type as date in $project phase Created: 17/Jun/17  Updated: 29/Oct/23  Resolved: 14/Nov/17

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: 3.5.9

Type: Task Priority: Major - P3
Reporter: Emily Hall Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: eng-m, expression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
documents SERVER-9406 Allow treating ObjectId type as date ... Closed
Participants:
Days since reply: 6 years, 13 weeks, 1 day ago
Epic Link: DOCS: 3.6 Server

 Description   

Documentation Request Summary:

Aggregation date expressions will accept input of type ObjectId.

Engineering Ticket Description:

Since ObjectId() encompasses an approximation of insertion date it would be helpful if _id/things of ObjectId() type could be operated/projected the same way as Datetime type object.

{case}
{$project:{$year:"$_id"}} would extract year out of ObjectId().getTimestamp equivalent.{case}

One question would be whether ObjectId could be operated on directly via date/interval arithmetic. I.e. whether it can be used anywhere a date can be used returning a standard Datetime type as a result from say {$subtract:["$_id",86400000]} which can only return ts of one day before that ObjectId's timestamp.



 Comments   
Comment by Githook User [ 14/Nov/17 ]

Author:

{'name': 'Kevin Albertson', 'username': 'kevinAlbs', 'email': 'kevin.albertson@10gen.com'}

Message: DOCS-10404 date expressions may include ObjectID
Branch: master
https://github.com/mongodb/docs/commit/3f1857fd59346f39779f6d49fd5f6189fe1607da

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