C2=DATEDIF(A2,B2,"Y")
D2=DATEDIF(A2,B2,"ym")
E2=DATEDIF(A2,B2,"md")
F2=DATEDIF(A2,B2,"Y")& " 年"&DATEDIF(A2,B2,"ym")&" 月"&DATEDIF(A2,B2,"md")& " 日"
照你的格式來處理
我只會用截字串(MID)的方式來做 公式有點長 不是很好讀
但可以實現
=IF(INT(MID(A1,FIND("年",A1)+1,FIND("月",A1)-FIND("年",A1)-1))>INT(MID(B1,FIND("年",B1)+1,FIND("月",B1)-FIND("年",B1)-1)),INT(MID(A1,1,FIND("年",A1)-1))-INT(MID(B1,1,FIND("年",B1)-1))&"年"&INT(MID(A1,FIND("年",A1)+1,FIND("月",A1)-FIND("年",A1)-1))-INT(MID(B1,FIND("年",B1)+1,FIND("月",B1)-FIND("年",B1)-1))&"月",INT(MID(A1,1,FIND("年",A1)-1))-1-INT(MID(B1,1,FIND("年",B1)-1))&"年"&INT(MID(A1,FIND("年",A1)+1,FIND("月",A1)-FIND("年",A1)-1))+12-INT(MID(B1,FIND("年",B1)+1,FIND("月",B1)-FIND("年",B1)-1))&"月")
拆解說明如下
IF(結束月份>開始月份,結束月份直接減開始月份,結束月份須借位-開始月份)
*結束月份>開始月份
INT(MID(A1,FIND("年",A1)+1,FIND("月",A1)-FIND("年",A1)-1))>INT(MID(B1,FIND("年",B1)+1,FIND("月",B1)-FIND("年",B1)-1))
*結束月份直接減開始月份
INT(MID(A1,1,FIND("年",A1)-1))-INT(MID(B1,1,FIND("年",B1)-1))&"年"&INT(MID(A1,FIND("年",A1)+1,FIND("月",A1)-FIND("年",A1)-1))-INT(MID(B1,FIND("年",B1)+1,FIND("月",B1)-FIND("年",B1)-1))&"月"
*結束月份須借位-開始月份
INT(MID(A1,1,FIND("年",A1)-1))-1-INT(MID(B1,1,FIND("年",B1)-1))&"年"&INT(MID(A1,FIND("年",A1)+1,FIND("月",A1)-FIND("年",A1)-1))+12-INT(MID(B1,FIND("年",B1)+1,FIND("月",B1)-FIND("年",B1)-1))&"月"
C2儲存格公式:
=QUOTIENT((LEFT(B2,FIND("年",B2,1)-1)-LEFT(A2,FIND("年",A2,1)-1))*12+(MID(B2, FIND("年",B2,1)+1,FIND("月",B2,1)-FIND("年",B2,1)-1)-MID(A2,FIND("年",A2,1)+1,FIND("月",A2,1)-FIND("年",A2,1)-1)),12)&"年"&MOD((LEFT(B2,FIND("年",B2,1)-1)-LEFT(A2,FIND("年",A2,1)-1))*12+(MID(B2,FIND("年",B2,1)+1,FIND("月",B2,1)-FIND("年",B2,1)-1)-MID(A2,FIND("年",A2,1)+1,FIND("月",A2,1)-FIND("年",A2,1)-1)),12)&"月"
再將公式複製到C3:C11儲存格。