Closed sonijem closed 6 years ago
A date in mongo json looks like this: { "$date" : "2017-01-01T00:00:00Z" }
. You can also use regular R datetime objects. Here is an example:
# Create some dates
df <- data.frame(
dates = Sys.time() + 1:4
)
# Insert data with dates
m <- mongolite::mongo("test")
m$insert(df)
# Read data back and check dates
out <- m$find()
out$dates
Thanks, Jeroren.... 👍
Hi I'm trying insert date but it is only taking as string.
mongo$update(query = paste0('{"_id": ', c, ' }'), update = paste0('{"$addToSet": {"values": { "date_data": "ISODate("',dat,'")" } } }'))
If i remove quotes from value: "ISODate("',dat,'")", its is giving invalid json object error and with quote it inserts as string.