[SERVER-32842] Timestamp support for $convert Created: 22/Jan/18  Updated: 30/Oct/23  Resolved: 19/Oct/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.2.0

Type: Improvement Priority: Major - P3
Reporter: Justin Seyster Assignee: Drew Paroski
Resolution: Fixed Votes: 1
Labels: query-44-grooming
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
is documented by DOCS-14879 [SERVER] Investigate changes in SERVE... Closed
Related
Backwards Compatibility: Fully Compatible
Participants:

 Description   

Support conversions between date and timestamp, as well as conversions from timestamp to any type that a date can be converted to.



 Comments   
Comment by Asya Kamsky [ 10/Mar/22 ]

For those on older version, there's a workaround for this:

 

{$toDate:{$dateToString:{date:"$timestampField"}}}
 

Comment by Githook User [ 18/Oct/21 ]

Author:

{'name': 'Bobby Morck', 'email': 'bobby.morck@mongodb.com', 'username': 'bmorck'}

Message: SERVER-32842 Timestamp support for $convert
Branch: master
https://github.com/mongodb/mongo/commit/e99ec2cde2134987506b708cf624cdc5ef4bdb77

Comment by Katya Kamenieva [ 05/Mar/21 ]

Though it would be uncommon for users to store their data as Timestamp, it is present in change streams events, so this feature would be useful.
I agree with Asya, that converting from Timestamp to Date should be enough.

Comment by Asya Kamsky [ 12/Sep/19 ]

Which should also apply to {$toDate:<Timestamp>}

Comment by Asya Kamsky [ 22/Jan/18 ]

I think just supporting {$convert:{input:Timestamp,to:”date”}} is sufficient.

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