ref.put("clock_time", new BasicDBObject("$lte","2015/01/21 17:57:55"));
ref.put("clock_time", new BasicDBObject("$gte","2015/01/21 17:57:51"));
用这种方法不行啊
这两句只有一句话起作用,哪句在前哪句起作用,不能两边的范围都卡住
见鬼了 - -
你键值一样,覆盖了。
http://blog.csdn.net/alen1985/article/details/9765457
哎呀 知道了 的确是覆盖了
java 操作mongodb 查询2个时间段的数据怎么弄??? 求大神
Mongo mongo = new Mongo("172.18.17.30", 27017);
DB db = mongo.getDB("sina_sport");
DBCollection coll = db.getCollection("tongjis_nba");
BasicDBObject query = new BasicDBObject();
query.put("cdt", new BasicDBObject("$gte",
"2016-03-30T00:00:00.000Z"));
int iCount = coll.find(query).count();
System.out.println(iCount);
返回为0
哥们,您这个问题怎么解决了,我也遇到了类似的问题,您帮忙看看问题出在哪里?
代码如下:
for(Document doc : collection.find(and(gte("releaseDate", new Date(2016, 7, 5, 15, 06, 40)), lte("releaseDate", new Date(2016, 7, 5, 15, 07, 10))))) {
System.out.println("name:" + doc.getString("name") + "\t"
+ "price:" + doc.getInteger("price") + "\t"
+ "version:" + doc.getString("version") + "\t"
+ "releaseDate:" + doc.getDate("releaseDate"));
}