Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
Error while storing date in MongoDB from R

I am using RMongo library for storing data in mongo from R. This is the script I am trying to run:

time <- "2016-12-31T23:55:43.002513Z";
mongo <- mongoDbConnect(dbName, hostName , port);
output <- dbInsertDocument(mongo, collectionName , paste0('{"Param1":', 1, ',"Param2":', 2, ',"TimeStamp":',time, '}', sep = "", collapse = ""));

Error I am getting is:

Error in .jcall(rmongo.object@javaMongo, "S", "dbInsertDocument",   collection,  : 
com.mongodb.util.JSONParseException: 
{"Param1":1,"Param2":2,"TimeStamp":2016-12-31T23:55:43.002513Z}
                                       ^

What format should I be passing the timestamp here?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Hi thanks SymbolixAU. This worked for me.

 library(mongolite)

 m <- mongo(collection = collectionName , db = dbName, url = hostName);

 df <- data.frame(Param1 = 1, Param2 = 2, TimeStamp=as.POSIXct(time,tz="UTC"));

 m$insert(df);

Just posting this for others' reference.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!