FOXTABLE根据身份证计算性别生日年龄

[复制链接]
查看3391 | 回复0 | 2019-9-22 13:17:26 | 显示全部楼层 |阅读模式

Select Case e.DataCol.Name
    Case "身份证号"
        If e.DataRow.IsNull("身份证号") Then  '身份证号码是否为空
            e.DataRow("出生日期") = Nothing  '如果为空,则清除出生日期
            e.DataRow("性别") = Nothing  '如果为空,则清除出生日期
            e.DataRow("年龄") = Nothing '如果为空,则清除年龄
        Else
            '否则从身份证号码列中提取出生日期
            e.DataRow("出生日期") = ReadBirthday(e.DataRow("身份证号"))
            e.DataRow("性别") = ReadSex(e.DataRow("身份证号"))
            Dim d As Date = ReadBirthday(e.DataRow("身份证号"))
            Dim y As Integer = d.year
            If format(d, "MMdd") <= Format(Date.Today, "MMdd") Then
                e.DataRow("年龄") = Date.Today.Year - y
            Else
                e.DataRow("年龄") = Date.Today.Year - y -1
            End If
        End If
End Select





声明:转载此文出于传递更多学习信息之目的。若有来源标注错误或侵犯了您的合法权益,请与我联系,我将及时更正、删除,谢谢。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 禁止注册

本版积分规则