Skip to content

Instantly share code, notes, and snippets.

@kf0jvt
Created September 18, 2013 12:47
Show Gist options
  • Save kf0jvt/6608677 to your computer and use it in GitHub Desktop.
Save kf0jvt/6608677 to your computer and use it in GitHub Desktop.
After importing json into mongo some date fields may be interpreted as text. This script will go through and convert those fields to dates in mongo.
/usr/bin/mongo yourdbname --eval "db.yourcollectionname.find().forEach(function(doc){doc.yourdatefield = new ISODate(doc.yourdatefield);db.yourcollectionname.save(doc)});"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment