I do not think you can change the type of a field with a single query. The easiest way is to convert the data rows to Date format using the ISODate function during insertion. But if you want to process the data that you have already inserted, you can do this with the following code using the mongodb console:
db.collection.find().forEach(function(element){ element.OrderDate = ISODate(element.OrderDate); db.collection.save(element); })
This code will process each element of your collection and change the type of the Orderdate field from String to Date .
Leonid Beschastny
source share