中國(guó)教程網(wǎng)zhangditony翻譯,轉(zhuǎn)載請(qǐng)保留此信息 .
datedif是一個(gè)十分方便的函數(shù),可以計(jì)算兩日期之間的天數(shù)、月數(shù)和年數(shù)
Datedif(start_date,end_date,unit)只是Excel為了沿襲Lotus123的一個(gè)函數(shù),屬于隱藏函數(shù)
語(yǔ)法
DATEDIF(start_date,end_date,unit)
Start_date 為一個(gè)日期,它代表時(shí)間段內(nèi)的第一個(gè)日期或起始日期
End_date 為一個(gè)日期,它代表時(shí)間段內(nèi)的最后一個(gè)日期或結(jié)束日期。
Unit 為所需信息的返回類型。
Unit 返回
"Y" 時(shí)間段中的整年數(shù)。
"M" 時(shí)間段中的整月數(shù)。
"D" 時(shí)間段中的天數(shù)。
"MD" start_date 與 end_date 日期中天數(shù)的差。忽略日期中的月和年。
"YM" start_date 與 end_date 日期中月數(shù)的差。忽略日期中的日和年。
"YD" start_date 與 end_date 日期中天數(shù)的差。忽略日期中的年
注意:start_date參數(shù)必須要比end_date參數(shù)早,否則函數(shù)返回錯(cuò)誤!
![1446549513560711.jpg 20070627_fc16c9a5e86204af0299rqtbcp1jaius[1].jpg](https://atts.w3cschool.cn/attachments/image/20151103/1446549513560711.jpg)
更多建議: