Foxtable(狐表)用户栏目专家坐堂 → 关于日期计算问题


  共有4388人关注过本帖平板打印复制链接

主题:关于日期计算问题

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/1/21 23:11:00 [只看该作者]

1、无法列出什么时候预期的。

 

2、看懂代码,再自由扩展,好么?

 

Dim dt_xyk As DataTable = DataTables("信用卡")
Dim dt_lsz As DataTable = DataTables("流水账")
Dim dt_dyyh As DataTable = DataTables("还款")
dt_dyyh.DataRows.Clear
Dim d As Date = new Date(Date.Today.Year, Date.Today.Month, 1)
Dim ds() As Date = {d, d.AddMonths(1)}
For Each d In ds
    For Each dr As DataRow In dt_xyk.DataRows
        Dim ndr As DataRow = dt_dyyh.AddNew
        ndr("账户名称") = dr("账户名称")
        ndr("账单日") = d.AddDays(dr("账单日")-1)
        ndr("转出") = dt_lsz.Compute("sum(金额)", "账户名称 = '" & ndr("账户名称") & "' and 日期 >= #" & ndr("账单日").addmonths(-1) & "# and 日期 <= #" & ndr("账单日") & "# and 类别 = '转出'")
        ndr("转入") = dt_lsz.Compute("sum(金额)", "账户名称 = '" & ndr("账户名称") & "' and 日期 >= #" & ndr("账单日").addmonths(-1) & "# and 日期 >= #" & ndr("账单日") & "# and 类别 = '转入'")
        Dim yq_out = dt_lsz.Compute("sum(金额)", "账户名称 = '" & ndr("账户名称") & "' and 日期 < #" & ndr("账单日").addmonths(-1) & "# and 类别 = '转出'")
        Dim yq_in = dt_lsz.Compute("sum(金额)", "账户名称 = '" & ndr("账户名称") & "' and 日期 < #" & ndr("账单日").addmonths(-1) & "# and 类别 = '转入'")

        ndr("信用额度") = dr("信用额度")
        ndr("当月应还") = ndr("转出") - ndr("转入") + yq_out + yq_in
        ndr("可用额度") = ndr("信用额度") - ndr("当月应还")
        If val(dr("还款日")) < val(dr("账单日")) Then
            ndr("还款日") = d.AddDays(dr("还款日")-1).AddMonths(1)
        Else
            ndr("还款日") = d.AddDays(dr("还款日")-1)
        End If
        If ndr("当月应还") > 0 Then
            If ndr("账单日") > Date.Today Then
                ndr("账单状态") = "未出账,没还款"
            Else
                ndr("账单状态") = "已出账,没还款"
            End If
        Else
            If ndr("账单日") > Date.Today Then
                ndr("账单状态") = "未出账,没还款"
            Else
                ndr("账单状态") = "已出账,已还款"
            End If
        End If
        ndr("账单月份") = Format(d, "yyyyMM")
    Next
Next


 回到顶部
总数 39 1 2 3 4 下一页