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"

上一篇:java设计模式-----代理模式


下一篇:app后端设计(php)