-- 作者:gaoyong30000
-- 发布时间:2012/1/15 11:23:00
-- [求助]这是什么情况 本周明明有很多记录,结果只出现2条?(案例已上传)
Dim b4 As Double Dim n As Integer = Date.Today.DayOfWeek Dim d1 As Date = iif(n=0,Date.today.Adddays(n-6),Date.today.Adddays(1-n)) Dim d2 As Date = iif(n=0,Date.today.Adddays(n),Date.today.Adddays(7-n)) b4 = Tables("现场检查").Compute("count(审核时间)","审核时间 >= #" & d1 & "# And 审核时间 <= #" & d2 & "#") output.show(d1) output.show(d2) output.show(b4)
结果为:
2012-01-09 2012-01-15 2
而表里记录为:
此主题相关图片如下:1.jpg
[此贴子已经被作者于2012-1-15 15:50:13编辑过]
|
-- 作者:gaoyong30000
-- 发布时间:2012/1/15 13:06:00
--
Dim b1 As WinForm.Label = e.Form.Controls("Label40") Dim b2 As WinForm.Label = e.Form.Controls("Label41") Dim b3 As WinForm.Label = e.Form.Controls("Label17") Dim b4 As WinForm.Label = e.Form.Controls("Label50") Dim b5 As WinForm.Label = e.Form.Controls("Label46") b1.Text = Tables("现场检查").Compute("count(审核状态)", "审核状态 = false and 录入时间 > #" & Today.AddDays(-1) & "#") b2.Text = Tables("现场检查").Compute("count(审核状态)", "审核状态 = false and 录入时间 < #" & Date.Today() & "#") b3.Text = Tables("现场检查").Compute("count(审核状态)", "审核时间 > #" & Today.AddDays(-1) & "#") Dim n As Integer = Date.Today.DayOfWeek Dim d1 As Date = iif(n=0,Date.today.Adddays(n-6),Date.today.Adddays(1-n)) Dim d2 As Date = iif(n=0,Date.today.Adddays(n),Date.today.Adddays(7-n)) Dim d3 As Date = New Date(Date.today.Year,Date.today.month,1) Dim d4 As Date = New Date(Date.today.Year,Date.today.month,Date.DaysInMonth(Date.today.Year,Date.today.Month)) b4.Text = Tables("现场检查").Compute("count(审核状态)","审核时间 >= #" & d1 & "# And 审核时间 <= #" & d2 & "#") b5.text = Tables("现场检查").Compute("count(审核状态)","审核时间 >= #" & d3 & "# And 审核时间 <= #" & d4 & "#")
表中的审核时间 和 录入时间 是yyyy-MM-DD HH:MM:SS 形式
d1,d2,d3,d4 是yyyy-MM-DD形式
原理上 只需要在代码里把 审核时间 录入时间 转化成 yyyy-mm-dd即可 和d1,d2,d3,d4 做比较了 但是实际操作了一下 转化d1-d4可以 但是不会把审核时间 录入时间 转化成yyyy-mm-dd
[此贴子已经被作者于2012-1-15 14:25:08编辑过]
|
-- 作者:gaoyong30000
-- 发布时间:2012/1/15 15:50:00
--
命令窗口代码执行一下 可以看出 本周的数据有问题
Dim b1 As Integer Dim b2 As Integer Dim b3 As Integer b1 = Tables("现场检查").Compute("count(审核状态)", "审核时间 > #" & Today.AddDays(-1) & "#") Dim n As Integer = Date.Today.DayOfWeek Dim d1 As Date = iif(n=0,Date.today.Adddays(n-6),Date.today.Adddays(1-n)) Dim d2 As Date = iif(n=0,Date.today.Adddays(n),Date.today.Adddays(7-n)) Dim d3 As Date = New Date(Date.today.Year,Date.today.month,1) Dim d4 As Date = New Date(Date.today.Year,Date.today.month,Date.DaysInMonth(Date.today.Year,Date.today.Month)) b2 = Tables("现场检查").Compute("count(审核状态)","审核时间 >= #" & d1 & "# And 审核时间 <= #" & d2 & "#") b3 = Tables("现场检查").Compute("count(审核状态)","审核时间 >= #" & d3 & "# And 审核时间 <= #" & d4 & "#") output.show(d1) output.show(d2) output.show(b2)
|