Quantcast
Channel: Data Science, Analytics and Big Data discussions - Latest topics
Viewing all articles
Browse latest Browse all 4448

Need help with rmongodb and date field filter criteria

$
0
0

@rumsinha wrote:

I need to retrieve data for last 2 years into R from mongodb.
So, I was trying the below code snippet but getting error in the call to mongo.find....can someone help?

the date field stored in the below format
"created" : ISODate("2004-09-21T20:51:41.000Z")

In R, my code is

# filter the dataset using query

query = mongo.bson.buffer.create()
startDate <- as.Date("2013-01-01")
endDate <- as.Date("2013-08-01")
mongo.bson.buffer.start.object(query ,"created")
mongo.bson.buffer.append(query, "$gt", startDate)
mongo.bson.buffer.append(query, "$lt", endDate)
mongo.bson.buffer.finish.object(query)
query = mongo.bson.from.buffer(query)

create the cursor

cursor = mongo.find(mongo, ns = DBNS, query = query, fields = fields, skip=0)

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles