In MongoDB, I have a document with a field called "ClockInTime" that was imported from CSV as a string.
What does an appropriate db.ClockTime.update() statement look like to convert these text based values to a date datatype?
In MongoDB, I have a document with a field called "ClockInTime" that was imported from CSV as a string.
What does an appropriate db.ClockTime.update() statement look like to convert these text based values to a date datatype?
This code should do it:
> var cursor = db.ClockTime.find()
> while (cursor.hasNext()) {
... var doc = cursor.next();
... db.ClockTime.update({_id : doc._id}, {$set : {ClockInTime : new Date(doc.ClockInTime)}})
... }