以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  日期格式转换问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=113534)

--  作者:edisontsui
--  发布时间:2018/1/17 16:52:00
--  日期格式转换问题
我想把日期格式的数据(比如2018-01-15),通过datacolchanged里面的代码来将年份、月份、日期抽取出来,分别放在数据栏的年份、月份和日期里面。如何写代码呢?谢谢。
--  作者:有点甜
--  发布时间:2018/1/17 17:40:00
--  

如果用表达式,参考

 

http://www.foxtable.com/webhelp/scr/1285.htm

 

如果写代码

 

If e.DataCol.Name = "日期" Then
    If e.NewValue = Nothing Then
        e.DataRow("年") = Nothing
       
        e.DataRow("月") = Nothing
       
        e.DataRow("日") = Nothing
    Else
        e.DataRow("年") = e.newvalue.year
       
        e.DataRow("月") = e.newvalue.month
       
        e.DataRow("日") = e.newvalue.day
    End If
End If