Search code examples
mongodbrmongo

Properly passing mongodb ISODate in R


I'm trying to read data from MongoDB to R through RMongo:

dbGetQueryForKeys(mongo, "daily", "{type:'AAA', date:{$gt:ISODate('2008-01-01')}}", "{_id:0, date:1}")

which gives me an error on ISODate. The query works perfectly from mongo command line. How should I pass the date for this to work properly?


Solution

  • Changing ISODate to an R's version of it worked:

    ISOdate(year=2008, month=1, day=1, hour=0)
    

    Importantly, hour did matter as by default it tries to adjust timezones for some reason.