Is there any method or function to convert int64 "637766000000000000" into date MongoDB
CodePudding user response:
assuming that int64 is a timestamp, you could use toDate
Mongo aggregation.
Mongo toDate official docs
CodePudding user response:
Check this
Aggregate
db.collection.aggregate([
{
$set: {
date: {
$toDate: {
$divide: [
{ $subtract: [ "$date", 621355968000000000 ] },
10000
]
}
}
}
}
])
Update
db.collection.update({},
[
{
$set: {
date: {
$toDate: {
$divide: [
{ $subtract: [ "$date", 621355968000000000 ] },
10000
]
}
}
}
}
],
{
multi: true
})