以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  计算年龄  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=140837)

--  作者:dcr111
--  发布时间:2019/9/16 8:20:00
--  计算年龄
老师,请问一下,年龄计算截止到2019/9/1,不是today,怎么改?
If e.DataCol.Name = "身份证号码" Then
    Dim dr As DataRow = e.DataRow
    If dr.IsNull("身份证号码") Then
        dr("性别") = Nothing
        dr("出生年月") = Nothing
        dr("年龄") = Nothing
    Else
        dr("性别") = ReadSex(dr("身份证号码")) 
        dr("出生年月") = ReadBirthday(dr("身份证号码"))
        Dim t As TimeSpan = Today - CDate(dr("出生年月"))
        dr("年龄") = Math.Round(t.TotalDays / 365.2422,2)
    End If
End If

--  作者:有点蓝
--  发布时间:2019/9/16 9:00:00
--  
Dim t As TimeSpan = cdate("2019-09-01") - CDate(dr("出生年月"))