PROBLEM:
Error when get Y-m-d from "SentTimestamp" : ISODate("2015-12-23T22:20:15Z")
DETAILS :
document :
{
...
"SentTimestamp" : ISODate("2015-12-23T22:20:15Z")
...
}
query :
db.foo.find({}, {$dateToString: {format:"%Y-%m-%d", date:"$SentTimestamp"}})
Error :
Error: error: {
"$err" : "Can't canonicalize query: BadValue >1 field in obj: { format: \"%Y-%m-%d\", date: \"$SentTimestamp\" }",
"code" : 17287
Can somebody explain how can I convert date to string, what is wrong above ?