Foxtable(狐表)用户栏目专家坐堂 → 关于计算年龄 EXCEL中=int(2017.02-B1)


  共有1428人关注过本帖树形打印复制链接

主题:关于计算年龄 EXCEL中=int(2017.02-B1)

帅哥哟,离线,有人找我吗?
有点色
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/2/26 15:23:00 [显示全部帖子]

If e.DataCol.name = "出生日期" Then
    If e.newvalue <> Nothing Then
        Dim y As Integer = e.NewValue.year
        If format(e.newvalue, "MMdd") <= Format(Date.Today, "MMdd") Then
            e.DataRow("年龄") = Date.Today.Year - y
        Else
            e.DataRow("年龄") = Date.Today.Year - y -1
        End If
    Else
        e.DataRow("年龄") = Nothing
    End If
End If

 

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


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/2/26 17:23:00 [显示全部帖子]

改成数据列,写到datacolchanged事件去

 

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

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/2/26 20:33:00 [显示全部帖子]


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/2/26 22:56:00 [显示全部帖子]

代码改一下

 

If e.DataCol.name = "出生年月" Then
    If e.newvalue <> Nothing Then

        Dim d As Date = New Date(e.newvalue.substring(0,4), e.newvalue.substring(5,2), 1)
        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
    Else
        e.DataRow("年龄") = Nothing
    End If
End If


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/2/26 22:58:00 [显示全部帖子]

If e.DataCol.name = "出生年月" Then
    If e.newvalue <> Nothing Then

        Dim d As Date = New Date(e.newvalue.substring(0,4), e.newvalue.substring(5,2), 1)
        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
    Else
        e.DataRow("年龄") = Nothing
    End If
End If


 回到顶部