How to use the DATEDIF function to calculate the time interval between two dates in Excel
How to use the DATEDIF function to calculate the time interval between two dates in Excel: Excel provides users with many functions to calculate dates and times. In this article, Buffcom.net will introduce how to use the DATEDIF function to calculate the time between two dates in Excel.
1. DATEDIF function structure
Function syntax: =DATEDIF(start_date, end_date, unit)
Where:
- Start_date: required argument, is the first date or start date of a time period.
- End_date: required argument, is the first date or end date of a time period.
- Unit: required argument, is the type of information you want to return.
Types of Unit argument:
- Y: Number of completed years in the time period.
- M: Number of completed months in the time period.
- D: Number of days in the time period.
- MD: Number of days between the days in start_date and end_date. Ignore the month and year.
- YM: Number of months between the months in start_date and end_date. Ignore the day and year.
- Yd: Number of days between the days in start_date and end_date. Ignore the year.
Note: If start_date is greater than end_date, the function will return the #NUM! error.
2. How to use the DATEDIF function
For example, we need to calculate the time period between two dates, 4/5/2015 and 11/12/2019, using different Unit arguments as shown in the image below.
As we can see, the function will calculate differently depending on the Unit argument:
- Y: Number of years between the two dates 4/5/2015 and 11/12/2019.
- M: Number of months between the two dates 4/5/2015 and 11/12/2019.
- D: Number of days between the two dates 4/5/2015 and 11/12/2019.
- MD: Number of days between the days 4 and 11.
- YM: Number of months between the months 5 and 12.
- Yd: Number of days between the two dates 4/5 and 11/12.
Therefore, this article has instructed you on how to use the DATEDIF function in Excel. Wish you success!