首先,我们要看一下我们数据库中的事件类型是什么格式:是date,还是datetime
为什么小于等于不生效?
如果数据库中的格式是:datetime,带时分秒:条件查询是: yyyy-mmm-dd,
原因:这里查询小于等于就是:2023-05-05 00:00:00,因此就会不生效,所以应该传 2023-05-05 23:59:59,或者代码再新增一天
方式一:时间范围方式:between ..... and ......
SELECT a.id,a.retail_id as retailId,a.retail_name as retailName,a.note,a.creat_user as creatUser,a.create_time as createTime,a.update_time as updateTime from t_goodssheet a WHERE a.retail_id ='4252038971614003328' AND a.create_time between '2023-05-04' AND '2023-05-05' AND a.dbsplitcode = '012' AND a.entid = '1' ORDER BY a.create_time DESC ;
方式二 :时间范围方式: >= 大于等于, <= 小于等于
SELECT a.id,a.retail_id as retailId,a.retail_name as retailName,a.entid,a.dbsplitcode,a.reject_reason as rejectReason,a.note,a.creat_user as creatUser,a.create_time as createTime,a.update_time as updateTime from t_newgoods a WHERE a.retail_id ='4252038971614003328' AND a.create_time >='2023-05-04 00:00:00' AND a.create_time <= '2023-05-05 23:59:59' a.entid = '1' ORDER BY a.create_time DESC ;
来源地址:https://blog.csdn.net/weixin_43744474/article/details/130576855