The example document of mongodb:
{
"_id" : ObjectId("512eef329d5d0c9415000025"),
"time" : NumberLong(1431973102)
}
I want to get the $dayOfMonth from a timestamp value saved in time attribute in aggreate query but I've this excepcion message:
uncaught exception: aggreate failed: {
"errmsg" : "exception: can't convert from BSON type NumberLong64 to Date",
"code" : 16006,
"ok" : 0
}
When I run this query:
db.getCollection('collection_name').aggregate([
{ $match: { '_id': ObjectId('512eef329d5d0c9415000025') } },
{ $project: { 'time': 1, "dayOfMonth": { $dayOfMonth: '$time' } } }
])
Any idea? Thank you.