Foxtable(狐表)用户栏目专家坐堂 → 按日/周/月/季,如何设置汇总


  共有5196人关注过本帖树形打印复制链接

主题:按日/周/月/季,如何设置汇总

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2013/12/5 19:48:00 [显示全部帖子]

 做了 月和季 的统计,其余的你照着改


Dim d As Date = e.Form.Controls("DateTimePicker1").value
Dim y As Integer = d.Year
Dim m As Integer = d.Month
Dim dt1 As New Date(y, m, 1) '按月统计
Dim q As Integer = math.Ceiling(d.month / 3)
Dim dt2 As New Date(y, 3 * (q - 1) + 1, 1) '获取该季度的第一天
Dim dt3 As New Date(y, 3 * q, Date.DaysInMonth(2011,3 * q)) '获取该季度的最后一天
Dim filter As String = ""
DataTables("汇总").StopRedraw
DataTables("汇总").DataRows.Clear
For Each xh As String In DataTables("库存流水帐").GetValues("型号", "型号 is not null")
    Dim ndr As DataRow = DataTables("汇总").AddNew
    ndr("型号") = xh
    filter = "型号 = '" & xh & "' and 时间 >= #" & dt1 & "# and 时间 < #" & dt1.AddMonths(1) & "#"
    ndr("入库统计_本月累计入库") = DataTables("库存流水帐").Compute("sum(入库数量)", filter)
    ndr("出库统计_本月累计出库") = DataTables("库存流水帐").Compute("sum(出库数量)", filter)
    filter = "型号 = '" & xh & "' and 时间 >= #" & dt2 & "# and 时间 < #" & dt3.AddDays(1) & "#"
    ndr("入库统计_本季累计入库") = DataTables("库存流水帐").Compute("sum(出库数量)", filter)
Next
DataTables("汇总").ResumeRedraw

 回到顶部