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 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 teach you all the methods to calculate date differences in Excel, from basic techniques to advanced scenarios.
1. Basic Date Difference Calculation
The simplest way to calculate days between 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 day count
Pro Tip:
Excel’s default date format is MM/DD/YYYY in US versions. If you’re using DD/MM/YYYY format, go to File > Options > Advanced and check “Use system separators” to match your regional settings.
Method 2: Using the DATEDIF Function
The DATEDIF function is specifically designed for date calculations and offers more flexibility:
=DATEDIF(start_date, end_date, unit)
| Unit Argument | Returns | Example Result (1/15/2023 to 2/20/2023) |
|---|---|---|
| “d” | Complete days between dates | 36 |
| “m” | Complete months between dates | 1 |
| “y” | Complete years between dates | 0 |
| “ym” | Months excluding years | 1 |
| “yd” | Days excluding years | 36 |
| “md” | Days excluding months and years | 5 |
2. Calculating Workdays (Excluding Weekends)
For business calculations, you often need to exclude weekends. Excel provides two main functions for this:
NETWORKDAYS Function
=NETWORKDAYS(start_date, end_date, [holidays])
- start_date: The beginning date of your period
- end_date: The ending date of your period
- holidays (optional): A range of dates to exclude (like company holidays)
Example: To calculate workdays between 1/1/2023 and 1/31/2023, excluding New Year’s Day (1/1/2023) and MLK Day (1/16/2023):
=NETWORKDAYS("1/1/2023", "1/31/2023", {"1/1/2023", "1/16/2023"})
This returns 21 workdays (23 calendar days minus 2 holidays and 4 weekend days).
NETWORKDAYS.INTL Function (More Flexible)
Introduced in Excel 2010, this function lets you define which days are weekends:
=NETWORKDAYS.INTL(start_date, end_date, [weekend], [holidays])
| Weekend Argument | Weekend Days | Description |
|---|---|---|
| 1 or omitted | Saturday, Sunday | Standard weekend (default) |
| 2 | Sunday, Monday | Common in some Middle Eastern countries |
| 3 | Monday, Tuesday | Custom weekend |
| 11 | Sunday only | Single weekend day |
| 12 | Monday only | Single weekend day |
| 13 | Tuesday only | Single weekend day |
| 14 | Wednesday only | Single weekend day |
| 15 | Thursday only | Single weekend day |
| 16 | Friday only | Single weekend day |
| 17 | Saturday only | Single weekend day |
Example: Calculate workdays with Friday and Saturday as weekends (common in some countries):
=NETWORKDAYS.INTL("1/1/2023", "1/31/2023", 7)
Where 7 represents Friday and Saturday as weekend days.
3. Advanced Date Calculations
Calculating Days Excluding Specific Weekdays
For more complex scenarios where you need to exclude specific weekdays (like a business that’s closed on Wednesdays), you can use a combination of functions:
=SUMPRODUCT(--(WEEKDAY(ROW(INDIRECT(A1&":"&B1)))={2,3,4,5,6}))
This counts only Monday through Friday between dates in A1 and B1.
Calculating Days Between Dates in Years, Months, and Days
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 from Birth Date
To calculate someone’s age from their birth date:
=DATEDIF(birth_date, TODAY(), "y")
Or for more precise age including months:
=DATEDIF(birth_date, TODAY(), "y") & " years, " & DATEDIF(birth_date, TODAY(), "ym") & " months"
4. Handling Time Zones and International Dates
When working with international dates, be aware of:
- Date Formats: US uses MM/DD/YYYY while most countries use DD/MM/YYYY
- Week Start: Some countries consider Monday as the first day of the week
- Holidays: National holidays vary by country
To ensure consistency:
- Use the
DATEfunction to create dates:=DATE(year, month, day) - For international workbooks, consider adding a note about the date format used
- Use
WORKDAY.INTLwith appropriate weekend parameters for different regions
5. Common Errors and Troubleshooting
| Error | Cause | Solution |
|---|---|---|
| #VALUE! | Non-date value entered | Ensure both arguments are valid dates or references to cells containing dates |
| #NUM! | Start date is after end date | Swap the dates or use ABS function: =ABS(B1-A1) |
| Incorrect day count | Dates stored as text | Use DATEVALUE to convert text to dates: =DATEVALUE("1/15/2023") |
| Negative numbers | Formula expects positive time span | Use ABS or ensure end date is after start date |
| #NAME? | Misspelled function name | Check function spelling (especially DATEDIF which isn’t in formula autocomplete) |
6. Practical Applications in Business
Mastering date calculations in Excel can significantly improve your business analysis:
Project Management
- Calculate project durations excluding weekends and holidays
- Create Gantt charts with accurate timelines
- Track milestones and deadlines
Human Resources
- Calculate employee tenure for benefits eligibility
- Track vacation accrual based on service time
- Analyze time-to-hire metrics
Finance
- Calculate interest periods for loans
- Determine billing cycles
- Analyze payment aging reports
Inventory Management
- Track product shelf life
- Calculate lead times from suppliers
- Analyze stock turnover rates
7. Excel vs. Google Sheets Date Functions
While Excel and Google Sheets have similar date functions, there are some key differences:
| Feature | Excel | Google Sheets |
|---|---|---|
| Basic date subtraction | =B1-A1 | =B1-A1 |
| DATEDIF function | Available but not documented | Fully supported and documented |
| NETWORKDAYS | Available in all versions | Available |
| NETWORKDAYS.INTL | Available in 2010+ | Available |
| Date format recognition | Strict (may require manual formatting) | More flexible automatic recognition |
| TODAY function updates | Updates when workbook opens or recalculates | Updates continuously in real-time |
| Array formulas for date ranges | Requires Ctrl+Shift+Enter in older versions | Handles array formulas natively |
8. Automating Date Calculations with VBA
For advanced users, Excel’s VBA (Visual Basic for Applications) can create custom date functions:
Function CustomWorkdays(start_date As Date, end_date As Date, Optional holidays As Range) As Long
Dim total_days 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 day is weekday (Mon-Fri)
If Weekday(current_date, vbMonday) <= 5 Then
' Check if current day is not in holidays range
is_holiday = False
If Not holidays Is Nothing Then
For Each cell In holidays
If cell.Value = current_date Then
is_holiday = True
Exit For
End If
Next cell
End If
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 custom function:
- Press Alt+F11 to open VBA editor
- Insert > Module
- Paste the code above
- Close VBA editor
- In your worksheet, use:
=CustomWorkdays(A1, B1, D1:D10)where D1:D10 contains holidays
9. Best Practices for Date Calculations
- Always use date functions: Instead of manual calculations, use Excel's built-in date functions for accuracy
- Document your formulas: Add comments explaining complex date calculations
- Use named ranges: For frequently used date ranges (like fiscal years)
- Validate inputs: Use data validation to ensure cells contain valid dates
- Consider time zones: When working with international data, standardize on UTC or a specific time zone
- Test edge cases: Verify your formulas work with:
- Same start and end dates
- Dates spanning month/year boundaries
- Leap years (especially February 29)
- Negative date ranges (end before start)
- Use helper columns: For complex calculations, break them into steps in separate columns
- Format consistently: Apply consistent date formatting throughout your workbook
10. Frequently Asked Questions
Q: Why does Excel show ###### instead of my date?
A: This happens when the column isn't wide enough to display the date format. Either widen the column or change to a shorter date format.
Q: How do I calculate the number of weeks between dates?
A: Divide the day count by 7: =ROUNDDOWN((B1-A1)/7, 0) for whole weeks, or =(B1-A1)/7 for decimal weeks.
Q: Can I calculate business hours between dates?
A: Yes, but it requires a more complex formula combining date and time functions. For 9-5 business hours:
=NETWORKDAYS(A1,B1)*9 + IF(NETWORKDAYS(B1,B1), MEDIAN(MOD(B1,1), 0.7, 0.3), 0) - IF(NETWORKDAYS(A1,A1), MEDIAN(MOD(A1,1), 0.7, 0.3), 0)This assumes 8-hour workdays (0.3 = 7AM, 0.7 = 5PM in Excel's time system).
Q: How do I handle time zones in date calculations?
A: Excel doesn't natively handle time zones. Best practices:
- Store all dates in UTC
- Add time zone information in separate columns
- Use Power Query to convert time zones if needed
- Consider using Excel's
TIMEfunction to adjust for time differences
Q: Why is DATEDIF not in Excel's formula autocomplete?
A: DATEDIF is a legacy function from Lotus 1-2-3 that Microsoft kept for compatibility but never officially documented until recent versions. It works perfectly but won't appear in the formula builder.
Q: How do I calculate the number of months between dates, ignoring the day?
A: Use: =DATEDIF(A1,B1,"m") for complete months, or =YEAR(B1)*12+MONTH(B1)-(YEAR(A1)*12+MONTH(A1)) for total months including partial months.
Q: Can I calculate days between dates in Excel Online?
A: Yes, all the functions mentioned (DATEDIF, NETWORKDAYS, etc.) work in Excel Online with the same syntax as desktop versions.