Score
0
Watch 1.1K Star 4.6K Fork 2.3K

季圣华 / 华夏ERPJavaGPL-3.0

按月份进行数据查询时,月份结束时间有问题,没有做大小月,闰月判断,直接是31日,导致查询时后台报错

Open
崔明  Opened this issue

典型代码如下:
String timeA = monthTime+"-01 00:00:00";
String timeB = monthTime+"-31 23:59:59";

需要针对timeB做大小月,闰年闰月判断,否则无法正常查询数据。

total 2 participants

Comments (1)

dean.xia 2020-04-27 09:40

遇到同样问题,建议修改为:
dh.OperTime >= '2019-11-01 00:00:00' AND dh.OperTime < '2019-12-01 00:00:00'
也就是时间段搜索中,开始时间以“>=本时间段起点”过滤,结束时间以“<下个时间段起点”过滤

SQL: SELECT ifnull(sum(DiscountLastMoney), 0) AS allMoney FROM jsh_depothead dh WHERE 1 = 1 AND dh.type = '入库' AND dh.subType = '采购' AND dh.OperTime >= '2019-11-01 00:00:00' AND dh.OperTime <= '2019-11-31 23:59:59' AND ifnull(dh.delete_Flag, '0') != '1'
### Cause: java.sql.SQLException: Incorrect DATETIME value: '2019-11-31 23:59:59'
; uncategorized SQLException; SQL state [HY000]; error code [1525]; Incorrect DATETIME value: '2019-11-31 23:59:59'; nested exception is java.sql.SQLException: Incorrect DATETIME value: '2019-11-31 23:59:59'

Sign in to comment

Assignees
Labels
Not set
Projects
Milestones
Branches
Planed to start
Not set
Planed to end
Not set
Top level
Priority