Spring Data MongoDB Date between two Dates

Deadly 提交于 2019-12-05 03:34:55

If you want to find docs where date is between the startDate and endDate of a b array element then you need to reverse your gte and lte calls:

Query query = new Query(Criteria.where("b").elemMatch(
    Criteria.where("startDate").lte(date)
    .and("endDate").gte(date)
);
Simon Liu
{"created_at":{$gt:ISODate("2013-04-30T00:00:00Z"),$lt:ISODate("2013-04-30T23:59:59Z")}}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!