Calculating the number of days between two dates in Excel is a common and widely used task in office work. Let Mytour show you a fast and accurate method to determine the days between two dates in Excel.

I. What is the DATEDIF Function in Excel?
Excel operates by combining various functions to perform calculations or generate content based on user needs. Mastering these functions helps users save time and achieve precise results in their computations.
The DATEDIF function in Excel calculates the number of days, months, or years between two specified dates. When you need to determine the duration between dates, simply use the DATEDIF function for automatic and time-efficient calculations.
The DATEDIF function operates straightforwardly: input the start date and end date, and it will automatically compute the difference in days, months, or years.
1. DATEDIF Function Formula
|
=DATEDIF(start_day,end_day,unit) |
Where:
- start_day: The starting date for calculation.
- end_day: The ending date for calculation.
- unit: the unit (day, month, year) (optional based on personal needs).
- If the unit value is “d,” the function will return the number of days.
- If the unit value is “m,” the function will return the number of months.
- If the unit value is “y,” the function will return the number of years.
Note:
- Ensure the date format is correct before applying the function to calculate the number of days between two dates.
- The DATEDIF function can provide one unit value or all three unit values simultaneously.
II. How to Accurately Calculate the Number of Days Between Two Dates in Excel
1. How to Calculate the Number of Days Between Two Dates
One of the most basic applications of the DATEDIF function is calculating the number of days between two specified dates. When using DATEDIF, you need to input the 'Start Date' and 'End Date' in two separate Excel cells. Then, use the following formula:
| Mẫu |
=DATEDIF(X,Y,"d") |
|
Ví dụ |
=DATEDIF(B2,C2,"d") |
Where:
- X; Y are the cell coordinates for calculating the day difference
- D: The unit of time measurement is day

2. How to Calculate the Number of Months Between Two Dates
Calculating the number of months between two dates using the DATEDIF function is also widely used in various documents. For files that don’t require excessive detail, calculating the difference in months provides easily trackable figures.
| Mẫu |
=DATEDIF(X,Y,"m") |
|
Ví dụ |
=DATEDIF(B2,C2,"m") |
Where:
- X; Y are the cell coordinates for calculating the date difference
- M: The unit of time measurement is month

3. How to Calculate the Number of Years Between Two Dates
Using the DATEDIF function to calculate the number of years between two predefined dates in Excel helps you quickly determine age, contract duration, and more. This method is widely adopted by accountants to save time on computer-based tasks. The formula for calculating the number of years between two dates is as follows:
| Mẫu |
=DATEDIF(X,Y,"y") |
|
Ví dụ |
=DATEDIF(B2,C2,"y") |
Where:
- X; Y are the cell coordinates for calculating the date difference
- Y: The unit of time measurement is year

4. How to Calculate Days, Months, and Years Between Two Dates in Detail
Beyond basic calculations, there’s a comprehensive formula that converts the total number of days into detailed and precise 'Years, Months, Days.' This method ensures you get exact figures for each specific unit.
| Mẫu |
=DATEDIF(X,Y,”y”)&“years, “ |
|
Ví dụ |
=DATEDIF(B2,C2,”y”)&“years, “ |
Where:
- X; Y are the cell coordinates for calculating the date difference
- years, months, days are the units to display in the result, which can be translated into Vietnamese as Năm, tháng, ngày if needed.
Note:
- When entering an extended function, press Alt + Enter to create a new line in Excel.
- If the input cell doesn’t display fully, press Ctrl + Shift + U to expand the data input cell.

In this article, Mytour has shared a quick and accurate method to calculate the number of days between two dates. Wishing you success!
