数据库以时间为搜索条件,出现的结果不正确
发布于 6 年前 作者 weiwu 8462 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

在搜索的时候,按照规定期间进行查询,返回的查询结果不正确,比如我的数据里的日期是2019-8-1,搜索条件是大于8月1日小与8月31日,但是8月1日的这一条出不来,

云上查不出,在本地调试又可以查到这一条,我上传了N次云函数还是不能查出,所以看有什么解决的办法

  • 预期表现
  • 复现路径
  • 提供一个最简复现 Demo

var begin, end;

if (event.year && event.month) {

begin = new Date(event.year, event.month - 1, 1);

end = new Date(event.year, event.month, 0);

}

return await alarmCollection.where({

targetDate: cmd.gte(begin).and(cmd.lte(end))

}).get().then(res => {

return res;

});

2 回复

如果a>1  你说a包括1嘛  明显不

你的搜索条件不是1<a<31 ,你在加个等于试试呢

回到顶部