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 days between dates in Excel, including handling weekends, holidays, and custom date ranges.
Why Date Calculations Matter
According to a Microsoft productivity study, 68% of Excel users regularly perform date calculations for business purposes. Proper date management can improve project accuracy by up to 40% and reduce scheduling errors by 35%.
Basic Method: Simple Day Count
The simplest way to calculate days between two dates is to subtract the earlier date from the later date:
- 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 the result as a number (not a date) by selecting the cell and choosing “Number” format
This will give you the total number of days between the two dates, including weekends and holidays.
Advanced Methods
1. Using the DATEDIF Function
The DATEDIF function is specifically designed for date calculations:
=DATEDIF(start_date, end_date, "d")
Where “d” returns the number of days between the dates. Other units you can use:
- “m” – Complete months between dates
- “y” – Complete years between dates
- “ym” – Months excluding years
- “yd” – Days excluding years
- “md” – Days excluding months and years
2. Calculating Workdays Only (NETWORKDAYS Function)
To exclude weekends and optionally holidays:
=NETWORKDAYS(start_date, end_date, [holidays])
Example with holidays:
=NETWORKDAYS(A1, B1, D1:D5)
Where D1:D5 contains a list of holiday dates.
| Function | Description | Example | Result |
|---|---|---|---|
| =B1-A1 | Basic subtraction | =DATE(2023,12,31)-DATE(2023,1,1) | 364 |
| DATEDIF | Flexible date difference | =DATEDIF(DATE(2023,1,1),DATE(2023,12,31),”d”) | 364 |
| NETWORKDAYS | Workdays excluding weekends | =NETWORKDAYS(DATE(2023,1,1),DATE(2023,1,31)) | 21 |
| NETWORKDAYS.INTL | Custom weekend parameters | =NETWORKDAYS.INTL(DATE(2023,1,1),DATE(2023,1,31),11) | 26 (Sun only) |
Handling Holidays and Custom Date Ranges
1. Excluding Holidays
Create a range with your holiday dates (e.g., E1:E10) and reference it in the NETWORKDAYS function:
=NETWORKDAYS(A1, B1, E1:E10)
2. Custom Weekend Days
Use NETWORKDAYS.INTL to define which days are weekends:
=NETWORKDAYS.INTL(start_date, end_date, [weekend], [holidays])
Weekend number codes:
- 1 – Saturday, Sunday (default)
- 2 – Sunday, Monday
- 3 – Monday, Tuesday
- 11 – Sunday only
- 12 – Monday only
- 13 – Tuesday only
- 14 – Wednesday only
- 15 – Thursday only
- 16 – Friday only
- 17 – Saturday only
3. Using Array Formulas for Complex Patterns
For irregular patterns (e.g., every other Friday), use array formulas:
=SUM(--(WEEKDAY(ROW(INDIRECT(A1&":"&B1)))={2,3,4,5,6}))
This counts only Monday through Friday between two dates.
Common Errors and Solutions
| Error | Cause | Solution |
|---|---|---|
| #VALUE! | Non-date values in formula | Ensure both arguments are valid dates or date serial numbers |
| #NUM! | End date before start date | Swap the date order or use ABS function: =ABS(B1-A1) |
| Incorrect count | Dates stored as text | Use DATEVALUE to convert: =DATEDIF(DATEVALUE("1/1/2023"),B1,"d") |
| ###### | Column too narrow | Widen the column or change number format |
Practical Applications
1. Project Management
Calculate project duration excluding weekends:
=NETWORKDAYS(project_start, project_end)
2. Employee Tenure
Calculate years, months, and days of service:
=DATEDIF(hire_date, TODAY(), "y") & " years, " & DATEDIF(hire_date, TODAY(), "ym") & " months, " & DATEDIF(hire_date, TODAY(), "md") & " days"
3. Financial Calculations
Calculate interest periods:
=YEARFRAC(start_date, end_date, basis)
Where basis defines the day count convention (0-4).
4. Age Calculation
Calculate exact age in years:
=DATEDIF(birth_date, TODAY(), "y")
Excel Version Differences
Date functions work similarly across Excel versions, but newer versions offer enhancements:
- Excel 365/2021: Supports dynamic arrays with date functions, allowing spill ranges
- Excel 2019: Added NETWORKDAYS.INTL function for custom weekends
- Excel 2016: Improved date handling with ISO week number functions
- Excel Online: Full functionality but may have calculation limits with very large date ranges
Best Practices for Date Calculations
- Always use cell references: Avoid hardcoding dates in formulas for flexibility
- Validate date entries: Use Data Validation to ensure proper date formats
- Document your formulas: Add comments explaining complex date calculations
- Consider time zones: For international projects, standardize on UTC or a specific time zone
- Test edge cases: Verify calculations with dates spanning month/year boundaries
- Use named ranges: For frequently used date ranges (e.g., “ProjectStart”)
- Format consistently: Apply the same date format throughout your workbook
Pro Tip: Date Serial Numbers
Excel stores dates as serial numbers where January 1, 1900 = 1. This system allows date arithmetic. To see the serial number, format a date cell as “General”. Understanding this can help debug date calculations.
Alternative Methods
1. Using Power Query
For large datasets, use Power Query to:
- Load your data with dates
- Add a custom column with Duration.Days([EndDate]-[StartDate])
- Load the results to a new worksheet
2. VBA Macros
For complex recurring calculations, create a VBA function:
Function DaysBetween(startDate As Date, endDate As Date, Optional includeWeekends As Boolean = True) As Long
Dim days As Long
days = endDate - startDate
If Not includeWeekends Then
days = days - (Application.WorksheetFunction.RoundDown(days / 7, 0) * 2)
If Weekday(startDate) > Weekday(endDate) Then days = days - 2
If Weekday(startDate) = vbSunday Then days = days - 1
If Weekday(endDate) = vbSaturday Then days = days - 1
End If
DaysBetween = days
End Function
3. Pivot Tables
Analyze date ranges by:
- Grouping dates by day, month, or year
- Adding calculated fields for duration
- Using timeline filters for interactive analysis
Frequently Asked Questions
Why does Excel show ###### instead of my date calculation?
This typically indicates the column isn’t wide enough to display the result. Either widen the column or change the number format to a shorter date format.
How do I calculate only weekdays between two dates?
Use the NETWORKDAYS function: =NETWORKDAYS(start_date, end_date). This automatically excludes Saturdays and Sundays.
Can I calculate business days excluding specific holidays?
Yes, use the NETWORKDAYS function with a holiday range: =NETWORKDAYS(A1, B1, D1:D10) where D1:D10 contains your holiday dates.
Why is my DATEDIF result negative?
This occurs when your end date is earlier than your start date. Either reverse the dates or use the ABS function: =ABS(DATEDIF(start, end, "d")).
How do I calculate the number of months between dates?
Use DATEDIF with “m”: =DATEDIF(start_date, end_date, "m"). For partial months, use “ym” to get months excluding complete years.
Can I calculate days between dates in different worksheets?
Yes, reference the full path: =DATEDIF(Sheet1!A1, Sheet2!B1, "d").
How do I handle time components in date calculations?
Use INT to remove time: =INT(end_date)-INT(start_date), or include time with: =(end_date-start_date)*24 for hours.
Conclusion
Mastering date calculations in Excel is an essential skill for data analysis, project management, and financial modeling. By understanding the various functions available—from simple subtraction to advanced NETWORKDAYS.INTL—you can handle virtually any date-based calculation requirement.
Remember these key points:
- Use basic subtraction for total days between dates
- NETWORKDAYS excludes weekends automatically
- NETWORKDAYS.INTL allows custom weekend definitions
- DATEDIF offers flexible unit returns (days, months, years)
- Always validate your date inputs to avoid errors
- Consider time zones for international date calculations
- Document complex date formulas for future reference
For most business applications, combining NETWORKDAYS with a holiday list provides the most accurate workday calculations. For more complex scenarios, consider using Power Query or VBA macros to automate repetitive date calculations.