Spring Data MongoDB Date Between

后端 未结 9 2020
臣服心动
臣服心动 2020-12-23 17:47

I use spring data mongodb.

I want the records between two dates. The following MongoDB Query works:

db.posts.find({startDate: {$gte: start, $lt: end}         


        
9条回答
  •  难免孤独
    2020-12-23 18:11

    I had to find dates between on field publishedDate and here is how I did it:

        Criteria publishedDateCriteria = Criteria
                            .where("publishedDateObject").gte(psDate)
                            .lte(peDate);
        Query query = new Query(publishedDateCriteria);
        mongoTemplate.find(query,
                            MyDocumentObject.class));
    

提交回复
热议问题