I'm currently pulling my data into R with the RMongo package. I want to specify the date range that should be pulled in my R session at this point with
library('RMongo')
#Connect to the database
mongo <- mongoDbConnect('db')
#results from dates.
result <- dbGetQuery(mongo, 'statsdb', '<query>', 0,200000)
Where my <query> is
{ "createdAt" : { "$gte" : ISODate("2012-12-01T00:00:00Z"), "$lt" : ISODate("2013-01-01T00:00:00Z") } }
I'm getting errors:
Error in .jcall(rmongo.object@javaMongo, "S", "dbGetQuery", collection, : com.mongodb.util.JSONParseException:
Is there a specific way i need to pass mongodb ISODates in R with the RMongo package?
I just spent considerable time struggling with this myself. If you're still looking for an answer, the key seems to be in MongoDB extended JSON; see
http://docs.mongodb.org/manual/reference/mongodb-extended-json/
For your query, you could write