0

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

felipsmartins
  • 13,269
  • 4
  • 48
  • 56
user3165854
  • 1,505
  • 8
  • 48
  • 100

1 Answers1

1

Just add new keyword to Date in your query

db.stores.update({"storeID" : "P0925"}, {$set : {"EffectiveEndDateTime": new Date()}}, {"multi" : true})
Med Lazhari
  • 608
  • 5
  • 9