I have some data like time:
{
timeStamp:1630504773861
}
and I want to do this:
1st: read timeStamp into aggregate
2nd: translate timestamp into ISO time
db.orders.aggregate([
{
$group:{
_id:null, "ISOtime": {$addToSet:new Date($timeStamp).toISOString()}}
}
])
but it works failed :
ReferenceError: $timeStamp is not defined
HOW SHOW I WRITE THIS AGGREGATAION?
mahisatya
(Mahi Satyanarayana)
2
Hi @yang_xiaoyu, welcome to the community.
Try using $toDate operator.
db.orders.aggregate([
{ $group:{ _id:null, "ISOtime": {$addToSet: { $toDate: "$timeStamp" }}} }
])
Mahi
it’s batter:
db.sf_license_config.aggregate([
{$group:{_id:"$_id", “ISOdate”: {$addToSet: {$toDate: “$timestamp”}}}}
])
system
(system)
Closed
5
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.