-- 作者:sxqq123
-- 发布时间:2013/11/21 20:01:00
--
执行代码如下:
If DataTables.Contains("动力月报") = False Then
DataTables.Load("动力月报")
End If
With Tables("动力日报")
.StopRedraw
For Each dr As DataRow In DataTables("动力日报").DataRows
Dim y As Integer = dr("日期").year
Dim m As Integer = dr("日期").Month
Dim d As Integer = dr("日期").day
Dim str As String = "时间=\'" & IIF(m=12 And d>=26,y+1,y) & "年" & IIF(d>=26,IIF(m=12,1,M+1),m) & "月\'"
Dim year As String = IIF(m=12 And d>=26,y+1,y)
Dim month As String = IIF(d>=26,IIF(m=12,1,M+1),m)
Dim ddate As Date = new Date(year, month, 26)
Dim dr0 As DataRow = DataTables("动力月报").Find(str)
If dr0 IsNot Nothing Then
dr("新水_月用量") = DataTables("动力日报").Compute("sum(新水_天用量)", "日期 <= #" & dr("日期") & "# and 日期 >= #" & ddate.AddMonths(-1) & "#")
dr("新水_月成本") = DataTables("动力日报").Compute("sum(新水_天成本)", "日期 <= #" & dr("日期") & "# and 日期 >= #" & ddate.AddMonths(-1) & "#")
ddate = new Date(year, 12, 26)
dr("新水_年用量") = DataTables("动力日报").Compute("sum(新水_天用量)", "日期 <= #" & dr("日期") & "# and 日期 >= #" & ddate.AddYears(-1) & "#")
dr("新水_年成本") = DataTables("动力日报").Compute("sum(新水_天成本)", "日期 <= #" & dr("日期") & "# and 日期 >= #" & ddate.AddYears(-1) & "#")
End If
Next
.ResumeRedraw
End With
|