r mongolite - date query

后端 未结 4 1437
执念已碎
执念已碎 2021-01-23 01:59

Question

Using the mongolite package in R, how do you query a database for a given date?

Example Data

4条回答
  •  情歌与酒
    2021-01-23 02:21

    @user2754799 has the correct method, but I've made a couple of small changes so that it answers my question. If they want to edit their answer with this solution I'll accept it.

    d <- as.integer(as.POSIXct(strptime("2015-01-01","%Y-%m-%d"))) * 1000
    ## or more concisely
    ## d <- as.integer(as.POSIXct("2015-01-01")) * 1000
    data <- mong$find(paste0('{"dte":{"$gt": { "$date" : { "$numberLong" : "', d, '" } } } }'))
    

提交回复
热议问题