Say I have a collection with objects like this, where the ts property contains an Unix Timestamp.
{
"_id" : ObjectId("50ef1e0f1e816a74ad835a5a"),
"ts" : 1357851660
}
Is there a way to convert the ts field to an ISODate using the Aggregation Framework, so I can use the date operators ($dayOfYear, $dayOfMonth, ...)?
All information and testing I could find out indicates this is not possible as of MongoDB 2.2.2. It's fairly easy to implement using Map/Reduce though.
Marking this as answered as this seems to be the best answer available right now, but I'm willing to review this in the future if new functionality is added to MongoDB to support this, or if someone comes up with a good workaround.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With