老师,如下代码倒可以取数了,但是在运行出现错误
Dim y As Integer = E.DataRow("RQ").Year
Dim m As Integer = E.DataRow("RQ").Month
Dim q As Integer = (E.DataRow("RQ").Month - 1) \ 3 + 1 '计算现在是第几个季度
Dim w As Integer = E.DataRow("RQ").DayOfWeek '算出今天是星期几
Dim dt1 As Date = E.DataRow("RQ").AddDays(-w) '获取本周的第一天
Dim dt2 As Date = E.DataRow("RQ").AddDays(6 - w) '获取本周的最后一天
Dim dt3 As New Date(y, m, 1)
Dim dt4 As New Date(y, m, Date.DaysInMonth(y, m)) '获取本月的最后一天
Dim dt5 As New Date(y, 3 * (q - 1) + 1, 1) '获取本季度的第一天
Dim dt6 As New Date(y, 3 * q, Date.DaysInMonth(y,3 * q)) '获取本季度的最后一天
Dim dt7 As Date = E.DataRow("RQ")
Dim dt8 As Date = E.DataRow("RQ").AddMonths(3) '加上3个月
Dim dt9 As Date = E.DataRow("RQ").AddMonths(6) '加上6个月
Dim dt10 As Date = E.DataRow("RQ").AddMonths(12) '加上12个月
Dim dt11 As Date = E.DataRow("RQ").AddMonths(24) '加上24个月
If e.DataCol.Name = "出piao人" Then
Dim filter1 As String = "出piao银行 = '" & e.DataRow("出piao银行") & "' And 出piao人 = '" & e.DataRow("出piao人") & "'"
e.DataRow("开piao金额") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [出piao日期] <= #" & dt7 & "# ")/10000
e.DataRow("到期需兑付金额") = DataTables("pjmxb").Compute("sum(到期需兑付金额)",filter1 & "And [出piao日期] <= #" & dt7 & "#" )/10000
e.DataRow("已兑付金额") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [兑付] = true" ) /10000
e.DataRow("本日到期金额") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] = #" & dt7 & "# ")/10000
e.DataRow("本日以前") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] >= #" & dt1 & "# And [到期日期] < #" & dt7 &"#" )/10000
e.DataRow("本周内到期金额") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] >= #" & dt7 & "# And [到期日期] <= #" & dt2 &"#" )/10000
e.DataRow("本日以前1") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] >= #" & dt3 & "# And [到期日期] < #" & dt7 &"#" )/10000
e.DataRow("本月内到期金额") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] >= #" & dt7 & "# And [到期日期] <= #" & dt4 &"#" )/10000
e.DataRow("本日以前2") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] >= #" & dt5 & "# And [到期日期] < #" & dt7 &"#" )/10000
e.DataRow("本季度内到期金额") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] >= #" & dt7 & "# And [到期日期] <= #" & dt6 &"#" )/10000
e.DataRow("三个月内到期金额") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] > #" & dt7 & "# And [到期日期] <= #" & dt8 &"#" )/10000
e.DataRow("六个月内到期金额") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] > #" & dt7 & "# And [到期日期] <= #" & dt9 &"#" )/10000
e.DataRow("一年内到期金额") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] > #" & dt7 & "# And [到期日期] <= #" & dt10 &"#" )/10000
e.DataRow("二年内到期金额") = DataTables("pjmxb").Compute("sum(开piao金额)",filter1 & "And [到期日期] > #" & dt7 & "# And [到期日期] <= #" & dt11 &"#" )/10000
End If
运行如下代码:
For Each r As Row In Tables("pjmxb").Rows
DataTables("pjtzhzb").datarows.clear
Dim f As New Filler
f.SourceTable = DataTables("pjmxb") '指定数据来源
f.SourceCols = "出piao行,出piao银行,出piao人" '指定数据来源列
f.DataTable = DataTables("pjtzhzb") '指定数据接收表
f.DataCols = "出piao行,出piao银行,出piao人" '指定数据接收列
f.ExcludeExistValue = True
f.Fill() '填充数据
Next
MainTable = Tables("pjtzhzb")
提示如下运行错误:
.NET Framework 版本:2.0.50727.8806
Foxtable 版本:2017.6.12.1
错误所在事件:表,pjtzhzb,DataColChanged
详细错误信息:
调用的目标发生了异常。
添加或减去的值产生无法表示的 DateTime。
参数名: value
[此贴子已经被作者于2021/11/12 15:38:08编辑过]