=IF(
OR(C2=IF(COUNTIF([按装箱日期核算超期的正大区.xlsx]Sheet1!$A:$A,C2)=0,"未知",C2),W1="备货单"),
IF(
IF(R2="",TODAY(),R2)>Q2,
IF(R2="",DATEDIF(Q2,TODAY(),"D"),DATEDIF(Q2,R2,"D")),
"0"),
IF(
IF(S2="",TODAY(),S2)>Q2,
IF(S2="",DATEDIF(Q2,TODAY(),"D"),DATEDIF(Q2,S2,"D")),
"0")
)