Foxtable(狐表)用户栏目专家坐堂 → 已知计划开始时间、计划完成时间以及计划工作量,如何求各月计划工作量


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

主题:已知计划开始时间、计划完成时间以及计划工作量,如何求各月计划工作量

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


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

参考代码

 

Dim sd As Date = "2017-06-08"
Dim ed As Date = "2017-10-19"
Dim count As Double = 1000
Dim sp As TimeSpan = ed-sd
Dim avg As Double = 1000 / (sp.TotalDays+1)

Dim i As Double = 0
Do While sd <= ed
    If sd.Day = 1 OrElse sd = ed Then
        output.show(format(sd.AddDays(-1), "yyyyMM") & " : " & i*avg)
        i = 1
    Else
        i += 1
    End If
    sd = sd.AddDays(1)
Loop


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


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

DataTables("表A").DataRows.Clear

MainTable = Tables("表A")

For Each r As Row In Tables("进度计划").Rows
    Dim sd As Date = r("计划开始")
    Dim ed As Date = r("计划完成")
    Dim count As Double = r("计划产值")
    Dim sp As TimeSpan = ed-sd
    Dim avg As Double = count / (sp.TotalDays+1)
    Dim i As Double = 0
    Dim sum As Double = 0
    Do While sd <= ed
        If sd.Day = 1 OrElse sd = ed Then
            Dim dr As DataRow = DataTables("表A").AddNew
            dr("项目ID") = r("项目ID")
            dr("计划ID") = r("计划ID")
            dr("月份") = format(sd.AddDays(-1), "yyyyMM")
            If sd = ed Then
                dr("产值") = count-sum
            Else

                dr("产值") = i*avg
                sum += i*avg
            End If
            i = 1
        Else
            i += 1
        End If
        sd = sd.AddDays(1)
    Loop
Next


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


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

DataTables("表A").DataRows.Clear
MainTable = Tables("表A")
For Each r As DataRow In DataTables("进度计划").Select("计划开始 is not null")
    Dim sd As Date = r("计划开始")
    Dim ed As Date = r("计划完成")
    Dim count As Double = r("计划产值")
    Dim sp As TimeSpan = ed-sd
    Dim avg As Double = count / (sp.TotalDays+1)
    Dim i As Double = 0
    Dim sum As Double = 0
    Do While sd <= ed
        If sd.Day = 1 OrElse sd = ed Then
            Dim dr As DataRow = DataTables("表A").AddNew
            dr("项目ID") = r("项目ID")
            dr("计划ID") = r("计划ID")
            dr("月份") = format(sd.AddDays(-1), "yyyyMM")
            If sd = ed Then
                dr("产值") = count-sum
            Else
                dr("产值") = i*avg
                sum += i*avg
            End If
            i = 1
        Else
            i += 1
        End If
        sd = sd.AddDays(1)
    Loop
Next

 回到顶部