EXCEL中录入身份证号后,怎样提取年龄和性别

2024-11-25 20:49:56
推荐回答(4个)
回答1:

因为D1是由B1计算出来的,所以你去掉B1,当然D1也变了。
只用一个公式就行了:
=YEAR(TODAY())-YEAR(TEXT(IF(LEN(A1)=15,"19"&MID(A1,7,2)&"-"&MID(A1,9,2)&"-"&MID(A1,11,2),MID(A1,7,4)&"-"&MID(A1,11,2)&"-"&MID(A1,13,2)),"yyyy-mm-dd"))

回答2:

B1是过渡公式,可以将D1的公式中的B1换成 B1的整个公式:

=YEAR(TODAY())-YEAR(TEXT(IF(LEN(A1)=15,"19"&MID(A1,7,2)&"-"&MID(A1,9,2)&"-"&MID(A1,11,2),MID(A1,7,4)&"-"&MID(A1,11,2)&"-"&MID(A1,13,2)),"yyyy-mm-dd"))

回答3:

=DATEDIF(IF(LEN(A1)=15,DATE(MID(A1,7,2),MID(A1,9,2),MID(A1,11,2)),DATE(MID(A1,7,4),MID(A1,11,2),MID(A1,13,2))),TODAY(),"y")

回答4:

D1计算年龄:
=DATEDIF(TEXT(MID(A1,7,LEN(A1)*2/3-4),"0-00-00"),TODAY(),"Y")