以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]格式化日期  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=113387)

--  作者:天一生水
--  发布时间:2018/1/15 9:33:00
--  [求助]格式化日期

 

DataColChanged事件,我想得到的月份格式为:01月、02月......11月、12月,加黑的代码不对,怎样修改?

谢谢!

If e.DataCol.Name = "立案日期" Then
    If e.DataRow.isnull("立案日期") Then
        e.DataRow("立案年份") = Nothing
        e.DataRow("立案月份") = Nothing
    Else
        e.DataRow("立案年份") = e.newvalue.Year & "年"
        e.DataRow("立案月份") = Format(e.newvalue.Month,"MM") & "月"
    End If
End If


--  作者:有点甜
--  发布时间:2018/1/15 9:37:00
--  
e.DataRow("立案月份") = Format(e.newvalue,"MM") & "月"
--  作者:有点甜
--  发布时间:2018/1/15 9:37:00
--  

或者

 

e.DataRow("立案月份") = Format(e.newvalue.Month,"00") & "月"