tags:

views:

132

answers:

1

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?

+4  A: 

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)}})
... }
kristina
That worked... thx...
Jeff Fritz