EXCEL计算根据当前时间和身份证号计算准确年龄

假设身份证号在A2单元格

=IF(MONTH(NOW())<MONTH(DATE(MID(A2,7,4),MID(A2,11,2),MID(A2,13,2))),INT(YEAR(NOW())-YEAR(DATE(MID(A2,7,4),MID(A2,11,2),MID(A2,13,2))))-1,IF(MONTH(NOW())>MONTH(DATE(MID(A2,7,4),MID(A2,11,2),MID(A2,13,2))),YEAR(NOW())-YEAR(DATE(MID(A2,7,4),MID(A2,11,2),MID(A2,13,2))),IF(DAY(NOW())>=DAY(DATE(MID(A2,7,4),MID(A2,11,2),MID(A2,13,2))),YEAR(NOW())-YEAR(DATE(MID(A2,7,4),MID(A2,11,2),MID(A2,13,2))),YEAR(NOW())-YEAR(DATE(MID(A2,7,4),MID(A2,11,2),MID(A2,13,2)))-1)))

其实也可以根据任意时期计算, 例如, 只需将NOW()替换为"2018-08-08"

posted @ 2019-01-07 10:45  LisPythoniC  阅读(3201)  评论(0编辑  收藏  举报