I have data like the following example in my mongoDB (collection: data_extraction_test):
{
"_id" : ObjectId("4f16fc97d1e2d32371003e27"),
"date" : "14 Nov 2000 08:22:00 -0800"
}
{
"_id" : ObjectId("4f16fc97d1e2d32371003e28"),
"date" : "14 Nov 2000 07:37:00 -0800"
}
{
"_id" : ObjectId("4f16fc97d1e2d32371003e29"),
"date" : "14 Nov 2000 07:25:00 -0800"
}
When running the javascript Code (extract is given below) the following error appears: Can't convert from BSON type string to Date
let cursor = col.aggregate([
{
$project:{
_id: "$_id",
year: {$year: new Date("13 Nov 2000 01:41:00 -0800 (PST)")},
// month: new Date(new String("$date")),
month: { $month: "$date" },
}
},
{
$out: "dan"
}
]).toArray((err, items)=>{
assert.equal(null, err);
console.log("daniel",items);
resolve(true);
db.close();
});
How can i convert the string into ISODate?