I\'m trying to use the mongodump command to dump out a bunch of records created on a specific date. The records include a \"ts\" field which is a MongoDB Date() object.
Edit: fixed typos
Add an update:
mongodump --query
doesn't support IsoDate
, but accepts Date
in milliseconds form.
As date
command behaves different in OS X, date -d 2011-08-10 +%s
does not work for me. If you've run into the same issue, try to read the manual or use this:
Get current time in seconds:
date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s"
Get specific time in seconds:
date -j -f "%Y-%m-%d %H:%M:%S" "2014-01-01 00:00:00" "+%s"
Use the single quote version to avoid escaping.
mongodump --query '{updated_at: { $gte: Date(1403280000000) } }'