如何在当天查询mongo

时间:2018-07-09 10:01:47

标签: mongodb timestamp

这是我的SQL查询

SELECT customer_id, verification_start_time, address_scoring 
from under_writing_limits 
where day(verification_start_time) = 25

但是我的数据在MongoDB中,通常我在熊猫上查询,但由于我的数据越来越大,所以今天不能这样做

2 个答案:

答案 0 :(得分:1)

可能有效

db.under_writing_limits.find(
        {25 :new Date(verification_start_time) },
        { customer_id: 1, verification_start_time: 1,address_scoring: 1 }
    )

答案 1 :(得分:1)

应该是这样

var myDate="25-01-2001";
myDate=myDate.split("-");
var newDate=myDate[1]+"/"+myDate[0]+"/"+myDate[2];
var date1 = new Date(newDate).getTime()

var myDate="25-07-2018";
myDate=myDate.split("-");
var newDate=myDate[1]+"/"+myDate[0]+"/"+myDate[2];
var date2 = new Date(newDate).getTime()


db.under_writing_limits.find(
  { verification_start_time: { $gte: date1, $lte: date2 } },
  { customer_id: 1, verification_start_time: 1, address_scoring: 1 }
)