Excel Days Between Dates Calculator
Calculate the exact number of days between two dates with Excel formulas – includes weekends, workdays, and custom date ranges
Complete Guide: How to Calculate Days Between Two Dates in Excel
Calculating the number of days between two dates is one of the most common tasks in Excel, whether you’re tracking project timelines, calculating employee tenure, or analyzing financial periods. This comprehensive guide will walk you through all the methods to calculate date differences in Excel, from basic to advanced techniques.
1. Basic Date Difference Calculation
The simplest way to calculate days between two dates is by subtracting one date from another. Excel stores dates as serial numbers (with January 1, 1900 as day 1), so basic arithmetic works perfectly.
Method 1: Simple Subtraction
- Enter your start date in cell A1 (e.g., 1/15/2023)
- Enter your end date in cell B1 (e.g., 2/20/2023)
- In cell C1, enter the formula:
=B1-A1 - Format cell C1 as “General” or “Number” to see the result as days
Example: If A1 contains 1/15/2023 and B1 contains 2/20/2023, the formula will return 36, meaning there are 36 days between these dates.
Method 2: Using the DATEDIF Function
The DATEDIF function (Date + Dif) is specifically designed for calculating date differences:
=DATEDIF(start_date, end_date, "D")
Where “D” returns the number of complete days between the dates.
| Unit | Return Value | Example Result |
|---|---|---|
| “D” | Complete days between dates | 36 |
| “M” | Complete months between dates | 1 |
| “Y” | Complete years between dates | 0 |
| “YM” | Months excluding years | 1 |
| “MD” | Days excluding months and years | 5 |
| “YD” | Days excluding years | 36 |
2. Calculating Workdays (Excluding Weekends)
For business calculations where you need to exclude weekends, Excel provides the NETWORKDAYS function:
=NETWORKDAYS(start_date, end_date, [holidays])
Parameters:
start_date: The beginning date of your periodend_date: The ending date of your period[holidays]: (Optional) A range of dates to exclude from the calculation
Example: To calculate workdays between 1/15/2023 and 2/20/2023 excluding weekends:
=NETWORKDAYS("1/15/2023", "2/20/2023")
This would return 26 workdays (assuming no holidays).
Including Holidays
If you have specific holidays to exclude:
- Create a list of holidays in a range (e.g., D1:D5)
- Use the formula:
=NETWORKDAYS(A1, B1, D1:D5)
3. Custom Workweek Calculations
For organizations with non-standard workweeks (e.g., companies that work Saturday but not Friday), use the NETWORKDAYS.INTL function:
=NETWORKDAYS.INTL(start_date, end_date, [weekend], [holidays])
Weekend Parameter Options:
- 1: Saturday, Sunday (default)
- 2: Sunday, Monday
- 3: Monday, Tuesday
- 4: Tuesday, Wednesday
- 5: Wednesday, Thursday
- 6: Thursday, Friday
- 7: Friday, Saturday
- 11: Sunday only
- 12: Monday only
- 13: Tuesday only
- 14: Wednesday only
- 15: Thursday only
- 16: Friday only
- 17: Saturday only
Example: For a company that works Monday-Saturday (Sunday off):
=NETWORKDAYS.INTL("1/15/2023", "2/20/2023", 11)
4. Advanced Date Calculations
Calculating Years, Months, and Days Separately
To break down the difference into years, months, and days:
=DATEDIF(A1, B1, "Y") & " years, " & DATEDIF(A1, B1, "YM") & " months, " & DATEDIF(A1, B1, "MD") & " days"
Calculating Age
For age calculations where you want the result in years:
=DATEDIF(birth_date, TODAY(), "Y")
Or for more precise age including months:
=DATEDIF(birth_date, TODAY(), "Y") & " years, " & DATEDIF(birth_date, TODAY(), "YM") & " months"
Calculating Due Dates
To add a specific number of workdays to a date (e.g., for project deadlines):
=WORKDAY(start_date, days, [holidays])
Example: To find a date 10 workdays after 1/15/2023:
=WORKDAY("1/15/2023", 10)
5. Handling Time in Date Calculations
When your dates include time components, you can:
- Use
=INT(end_date-start_date)to get whole days ignoring time - Use
=(end_date-start_date)*24to get the difference in hours - Use
=(end_date-start_date)*24*60to get the difference in minutes
6. Common Errors and Solutions
| Error | Cause | Solution |
|---|---|---|
| #VALUE! | Non-date value in date cell | Ensure both arguments are valid dates or date serial numbers |
| #NUM! | Start date is after end date | Swap the dates or use ABS function: =ABS(B1-A1) |
| ###### | Column too narrow to display date | Widen the column or change date format |
| Incorrect count | Time components affecting calculation | Use INT function: =INT(B1-A1) |
| Negative number | End date before start date | Use ABS function or correct date order |
7. Practical Applications
Project Management
Calculate project durations excluding weekends and holidays:
=NETWORKDAYS(project_start, project_end, holidays_range)
Employee Tenure
Calculate years of service for anniversary recognition:
=DATEDIF(hire_date, TODAY(), "Y")
Financial Calculations
Calculate interest periods for loans:
=DAYS360(start_date, end_date, [method])
Inventory Management
Track days since last inventory:
=TODAY()-last_inventory_date
8. Excel vs. Google Sheets Date Functions
| Function | Excel | Google Sheets | Notes |
|---|---|---|---|
| Basic date difference | =B1-A1 | =B1-A1 | Identical syntax |
| DATEDIF | =DATEDIF(A1,B1,”D”) | =DATEDIF(A1,B1,”D”) | Identical syntax |
| Networkdays | =NETWORKDAYS(A1,B1) | =NETWORKDAYS(A1,B1) | Identical syntax |
| Networkdays.Intl | =NETWORKDAYS.INTL(A1,B1,1) | =NETWORKDAYS.INTL(A1,B1,1) | Identical syntax |
| Workday | =WORKDAY(A1,10) | =WORKDAY(A1,10) | Identical syntax |
| Days360 | =DAYS360(A1,B1) | =DAYS(A1,B1) | Different functions with similar purpose |
| Today | =TODAY() | =TODAY() | Identical syntax |
| Now | =NOW() | =NOW() | Identical syntax |
9. Best Practices for Date Calculations
- Always validate your dates: Use ISNUMBER or DATEVALUE to ensure cells contain valid dates
- Be consistent with date formats: Stick to one format (e.g., MM/DD/YYYY) throughout your workbook
- Document your formulas: Add comments explaining complex date calculations
- Consider time zones: If working with international dates, account for time zone differences
- Use named ranges: For holiday lists to make formulas more readable
- Test edge cases: Try calculations with:
- Same start and end dates
- Dates spanning year boundaries
- Dates in different centuries
- February 29 in leap years
- Use data validation: Restrict date inputs to prevent errors
- Consider fiscal years: Some organizations use different year-start dates (e.g., July 1)
10. Automating Date Calculations with VBA
For repetitive date calculations, you can create custom VBA functions:
Function CustomWorkdays(start_date As Date, end_date As Date, Optional holidays As Range) As Long
Dim total_days As Long
Dim i As Long
Dim current_date As Date
Dim is_holiday As Boolean
total_days = 0
current_date = start_date
Do While current_date <= end_date
' Check if current_date is a weekday (Monday to Friday)
If Weekday(current_date, vbMonday) <= 5 Then
' Check if current_date is in holidays range
is_holiday = False
If Not holidays Is Nothing Then
For i = 1 To holidays.Rows.Count
If holidays.Cells(i, 1).Value = current_date Then
is_holiday = True
Exit For
End If
Next i
End If
' Count the day if it's a weekday and not a holiday
If Not is_holiday Then
total_days = total_days + 1
End If
End If
current_date = current_date + 1
Loop
CustomWorkdays = total_days
End Function
To use this function in your worksheet:
=CustomWorkdays(A1, B1, D1:D10)
11. Date Calculation Performance Tips
- Avoid volatile functions: TODAY() and NOW() recalculate with every worksheet change, which can slow down large workbooks
- Use helper columns: For complex calculations, break them into steps in separate columns
- Limit array formulas: They can be resource-intensive with large date ranges
- Use Excel Tables: For date ranges to enable structured references
- Consider Power Query: For very large date datasets (100,000+ rows)
- Cache results: For dashboards, calculate once and store the result