how to use excel to calculate days between dates

原创 admin 2021-01-09 05:29 

To get the number of days, weeks or years between two dates in Excel, use the DATEDIF function. The DATEDIF function has three arguments.

1. Fill in "d" for the third argument to get the number of days between two dates.

Days Between Two Dates in Excel

Note: =A2-A1 produces the exact same result!

2. Fill in "m" for the third argument to get the number of months between two dates.

Months Between Two Dates in Excel

3. Fill in "y" for the third argument to get the number of years between two dates.

Years Between Two Dates in Excel

4. Fill in "yd" for the third argument to ignore years and get the number of days between two dates.

Ignore Years, Get Days

5. Fill in "md" for the third argument to ignore months and get the number of days between two dates.

Ignore Months, Get Days

6. Fill in "ym" for the third argument to ignore years and get the number of months between two dates.

Ignore Years, Get Months

Important note: the DATEDIF function returns the number of complete days, months or years. This may give unexpected results when the day/month number of the second date is lower than the day/month number of the first date. See the example below.

Unexpected Result

The difference is 6 years. Almost 7 years! Use the following formula to return 7 years.

Year Function Twice

版权声明: 本文为4find – 解决程序猿问题原创文章,欢迎转载。转载请务必注明出处! (参考格式:本文转自4find – 解决程序猿问题,原文地址:http://4find.cc/archives/7189

发表评论


表情