date was save in below format using moment.
let date= moment().format('MMMM Do YYYY, h:mm:ss a');
When i try to get the year by using below code. I am getting Undefined as output
db.checkouts.aggregate(
{"$project":{ date:1,
"year":{"$year":"$date"},
total:1,
delivered:1,
count:1,
clientName:1,
clientId:1,
dealerId:1
}},{"$match":{
dealerId:status.UserNumber
}},function(err,o){
console.log(o);
if(o) callback(o);
}
)
Can I get the year from this date format?