以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  日期转为当月最后一天  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=116898)

--  作者:zoyong
--  发布时间:2018/4/2 14:27:00
--  日期转为当月最后一天

日期列自动变成每月的最后一天

 

比如录入:登记日期2018-03-03         变为       账务日期:2018-03-31

 

e.DataRow("日期") = “2018-03-03”

e.DataRow("账务日期") = “2018-03-31”

 

 

原代码:显示成本月了

 

If e.DataCol.Name = "日期" Then \'如果更改的是账务日期列
    If e.DataRow.IsNull("日期") Then \'账务日期是否为空
        e.DataRow("账务日期") = Nothing \'如果为空,则清除出生日期
    Else
        \'否则从账务日期列中提取出生日期
        e.DataRow("账务日期") = Format(e.DataRow("日期"), New Date(Date.today.Year, Date.Today.Month, Date.DaysInMonth(Date.today.Year, Date.Today.Month)))
        e.DataRow("年份") = Format(e.DataRow("账务日期"), "yyyy")    \'如果为空,则清除出生日期
        e.DataRow("月份") = Format(e.DataRow("账务日期"), "MM")    \'如果为空,则清除出生日期
    End If
    e.DataRow("工资月份") = e.DataRow("年份") & e.DataRow("月份")
End If

 

[此贴子已经被作者于2018/4/2 14:39:13编辑过]

--  作者:wyz20130512
--  发布时间:2018/4/2 14:40:00
--  
给个截图看看?
--  作者:有点甜
--  发布时间:2018/4/2 14:42:00
--  

Dim d As Date = e.DataRow("日期")

d = new date(d.year, d.month, 1)

e.DataRow("账务日期") = d.AddMonths(1).AddDays(-1)


 


--  作者:zoyong
--  发布时间:2018/4/2 14:56:00
--  
加一个月减一天        果然是高手