I am using mongoDB 3.4 and want to close documents in a mongoDB collection by setting an EffectiveEndDateTime
field to todays/current date time and want it in this format: yyyy-MM-dd HH:mm:ss.SSS
.
How can I specify the date format?
My current update query is:
db.stores.update({
"storeID": "P0925"
}, {
$set: {
"EffectiveEndDateTime": Date()
}
}, {
"multi": true
})
Thanks
Just add new keyword to Date in your query
db.stores.update({"storeID" : "P0925"}, {$set : {"EffectiveEndDateTime": new Date()}}, {"multi" : true})