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 walk you through all the methods to calculate days between dates in Excel, including handling weekends, holidays, and creating dynamic date calculations.
Basic Methods
- Simple subtraction (End Date – Start Date)
- DATEDIF function for precise year/month/day differences
- DAYS function (Excel 2013 and later)
Advanced Techniques
- Calculating workdays only (excluding weekends)
- Excluding custom holidays
- Creating dynamic date ranges
- Handling time components in date calculations
Practical Applications
- Project management timelines
- Employee tenure calculations
- Financial period analysis
- Contract expiration tracking
- Event planning schedules
Method 1: Basic Date Subtraction
The simplest way to calculate days between dates is to subtract the start date from the end date. Excel stores dates as serial numbers (with January 1, 1900 as day 1), so subtraction gives you the number of days between them.
Formula: =End_Date - Start_Date
Example: If cell A2 contains 15-Jan-2023 and cell B2 contains 20-Feb-2023, the formula =B2-A2 would return 36, which is the number of days between these dates.
| Date Format | Formula | Result | Notes |
|---|---|---|---|
| 15-Jan-2023 to 20-Feb-2023 | =B2-A2 | 36 | Basic subtraction works for any date format |
| 1-Mar-2023 to 15-Mar-2023 | =B3-A3 | 14 | Includes both start and end dates in count |
| 1-Jan-2023 to 31-Dec-2023 | =B4-A4 | 364 | Full year calculation (not leap year) |
Method 2: Using the DATEDIF Function
The DATEDIF function is a powerful but somewhat hidden Excel function that can calculate the difference between dates in days, months, or years. While Excel doesn’t document this function in its help files, it has been available since Excel 2000.
Syntax: =DATEDIF(start_date, end_date, unit)
Units available:
"d"– Days"m"– Complete months"y"– Complete years"ym"– Months excluding years"yd"– Days excluding years"md"– Days excluding months and years
Example: To get the number of days between two dates, use: =DATEDIF(A2,B2,"d")
| Unit | Formula | Result | Description |
|---|---|---|---|
| “d” | =DATEDIF(A2,B2,”d”) | 36 | Total days between dates |
| “m” | =DATEDIF(A2,B2,”m”) | 1 | Complete months between dates |
| “y” | =DATEDIF(A2,B2,”y”) | 0 | Complete years between dates |
| “ym” | =DATEDIF(A2,B2,”ym”) | 1 | Months excluding complete years |
| “yd” | =DATEDIF(A2,B2,”yd”) | 36 | Days excluding complete years |
Method 3: Using the DAYS Function (Excel 2013 and later)
For users with Excel 2013 or later, the DAYS function provides a straightforward way to calculate days between dates.
Syntax: =DAYS(end_date, start_date)
Example: =DAYS(B2,A2) would return the same result as the basic subtraction method.
Advantages of DAYS function:
- More readable than simple subtraction
- Less prone to errors from reversed date order
- Works consistently across different Excel versions (2013 and later)
Calculating Workdays (Excluding Weekends)
For business calculations, you often need to exclude weekends. Excel provides two main functions for this:
1. NETWORKDAYS Function
Syntax: =NETWORKDAYS(start_date, end_date, [holidays])
Example: =NETWORKDAYS(A2,B2) would return the number of workdays between two dates, automatically excluding Saturdays and Sundays.
To also exclude holidays, you can reference a range containing holiday dates:
=NETWORKDAYS(A2,B2,HolidaysRange)
2. WORKDAY.INTL Function (More Flexible)
The WORKDAY.INTL function (available in Excel 2010 and later) offers more flexibility in defining which days are considered weekends.
Syntax: =WORKDAY.INTL(start_date, end_date, [weekend], [holidays])
Weekend parameters:
1– Saturday, Sunday (default)2– Sunday, Monday3– Monday, Tuesday11– Sunday only12– Monday only13– Tuesday only14– Wednesday only15– Thursday only16– Friday only17– Saturday only
Example: To calculate workdays excluding only Sundays (6-day work week):
=WORKDAY.INTL(A2,B2,11)
Handling Holidays in Date Calculations
When calculating business days, you’ll often need to exclude holidays in addition to weekends. Here’s how to handle holidays in your calculations:
- Create a holiday list: Store your holidays in a range (e.g., D2:D20)
- Reference the range: Include the holiday range as the third argument in NETWORKDAYS or WORKDAY.INTL
- Use named ranges: For better readability, name your holiday range (e.g., “Holidays”)
Example with holidays:
=NETWORKDAYS(A2,B2,Holidays)
Dynamic holiday calculation: For holidays that occur on specific weekdays (like “third Monday in January”), you can use:
=DATE(year,month,1)+CHOSE(WEEKDAY(DATE(year,month,1)),0,6,5,4,3,2,1)+7*(week_number-1)
Common Errors and Solutions
When working with date calculations in Excel, you might encounter these common issues:
| Error | Cause | Solution |
|---|---|---|
| ###### (hash marks) | Column too narrow to display date | Widen the column or change date format |
| #VALUE! | Non-date value in date cell | Ensure both arguments are valid dates |
| #NUM! | Invalid date (e.g., February 30) | Check date validity and formatting |
| Negative number | End date before start date | Swap date order or use ABS function |
| Incorrect count | Time components affecting calculation | Use INT function to remove time: =INT(B2)-INT(A2) |
Advanced Techniques
1. Calculating Days Between Dates in Different Years
When comparing dates across year boundaries, you might want to break down the difference:
=DATEDIF(A2,B2,"y") & " years, " & DATEDIF(A2,B2,"ym") & " months, " & DATEDIF(A2,B2,"md") & " days"
2. Creating a Date Difference Calculator
Build an interactive calculator with data validation:
- Use Data Validation to create dropdown calendars
- Add conditional formatting to highlight invalid date ranges
- Create a results dashboard with multiple calculation methods
3. Handling Time Zones in Date Calculations
For international date calculations:
- Convert all dates to UTC using
=A2-(timezone_offset/24) - Use the
TIMEfunction to adjust for time differences - Consider daylight saving time changes in your calculations
4. Visualizing Date Differences with Charts
Create Gantt charts or timeline visualizations:
- Use a stacked bar chart with start dates as the baseline
- Calculate duration as the bar length
- Add data labels showing exact days
- Use conditional formatting for different project phases
Excel vs. Google Sheets Date Functions
While Excel and Google Sheets share many date functions, there are some differences:
| Function | Excel | Google Sheets | Notes |
|---|---|---|---|
| Basic subtraction | Yes | Yes | Works identically in both |
| DATEDIF | Yes (undocumented) | Yes (documented) | Same syntax and behavior |
| DAYS | Excel 2013+ | Yes | Google Sheets has had it longer |
| NETWORKDAYS | Yes | Yes | Identical functionality |
| WORKDAY.INTL | Excel 2010+ | Yes | Google Sheets added it later |
| Date serial number | 1 = 1-Jan-1900 | 1 = 1-Jan-1900 | But Google Sheets handles 1900 leap year correctly |
| Array formulas | CSE or dynamic arrays | Native array support | Google Sheets handles arrays more naturally |
Best Practices for Date Calculations
- Always validate dates: Use ISNUMBER or DATEVALUE to ensure cells contain valid dates
- Document your formulas: Add comments explaining complex date calculations
- Use named ranges: For holiday lists and other date references
- Consider time zones: Standardize on UTC or a specific time zone for international data
- Handle edge cases: Account for leap years, daylight saving time, and fiscal year boundaries
- Test with real data: Verify calculations with known date ranges
- Use helper columns: Break complex calculations into intermediate steps
- Format consistently: Apply the same date format throughout your workbook
Real-World Applications
1. Project Management
Calculate project durations, track milestones, and create Gantt charts:
- Use NETWORKDAYS for realistic project timelines
- Create conditional formatting to highlight overdue tasks
- Build dynamic timelines that update automatically
2. Human Resources
Track employee tenure, vacation accrual, and benefits eligibility:
- Calculate years of service for anniversary recognition
- Determine vacation accrual rates based on tenure
- Track probation periods for new hires
3. Finance and Accounting
Calculate interest periods, payment terms, and financial reporting periods:
- Determine days between invoice date and payment date
- Calculate interest accrual periods
- Verify financial reporting periods
4. Inventory Management
Track product shelf life, lead times, and reorder cycles:
- Calculate days since last inventory count
- Determine lead times from suppliers
- Monitor product expiration dates
Automating Date Calculations with VBA
For complex or repetitive date calculations, you can use VBA macros:
Example: Custom function to calculate business days excluding specific weekdays
Function CustomWorkdays(start_date As Date, end_date As Date, Optional exclude_days As Variant) As Long
Dim days_count As Long
Dim current_date As Date
Dim exclude_day As Variant
Dim day_of_week As Integer
days_count = 0
current_date = start_date
' Default to excluding Saturday (7) and Sunday (1)
If IsMissing(exclude_days) Then
exclude_days = Array(1, 7)
End If
Do While current_date <= end_date
day_of_week = Weekday(current_date, vbSunday)
If Not IsInArray(day_of_week, exclude_days) Then
days_count = days_count + 1
End If
current_date = current_date + 1
Loop
CustomWorkdays = days_count
End Function
Function IsInArray(value As Variant, arr As Variant) As Boolean
Dim element As Variant
For Each element In arr
If element = value Then
IsInArray = True
Exit Function
End If
Next element
IsInArray = False
End Function
To use this function in your worksheet: =CustomWorkdays(A2,B2,{1,7}) where {1,7} represents Sunday and Saturday.
Excel Date Calculation Resources
For more advanced date calculations and official documentation, refer to these authoritative sources:
- Microsoft Official DATEDIF Documentation
- Microsoft NETWORKDAYS Function Guide
- NIST Time and Frequency Division (for time zone standards)
- IRS Employer's Tax Calendar (for business date references)
Frequently Asked Questions
1. Why does Excel show ###### in my date cells?
This typically means the column isn't wide enough to display the date format. Either widen the column or change to a shorter date format (like "mm/dd/yyyy" instead of "Monday, January 15, 2023").
2. How do I calculate someone's age in Excel?
Use the DATEDIF function: =DATEDIF(birth_date,TODAY(),"y") for years, or combine units for more precision: =DATEDIF(birth_date,TODAY(),"y") & " years, " & DATEDIF(birth_date,TODAY(),"ym") & " months"
3. Can I calculate days between dates including only specific weekdays?
Yes, use the WORKDAY.INTL function with custom weekend parameters, or create a custom formula using SUMPRODUCT with WEEKDAY functions.
4. How do I handle leap years in my calculations?
Excel automatically accounts for leap years in its date system. The serial number for February 29 exists in leap years (like 2024) but not in common years. All standard date functions properly handle leap years.
5. Why does my date calculation give a different result than expected?
Common causes include:
- One of your "dates" is actually text that looks like a date
- Time components are affecting the calculation (use INT() to remove time)
- Different date systems (1900 vs 1904 date system in Excel preferences)
- Hidden characters or spaces in your date cells
6. How can I calculate the number of months between two dates?
Use DATEDIF with "m" unit: =DATEDIF(start_date,end_date,"m"). For decimal months (accounting for partial months), use: =YEARFRAC(start_date,end_date,1)*12
7. Is there a way to calculate days between dates excluding both weekends and specific holidays?
Yes, use the NETWORKDAYS function with a holiday range: =NETWORKDAYS(start_date,end_date,holidays_range). For more complex holiday patterns, you might need a custom formula.
8. How do I create a dynamic date range that updates automatically?
Use Excel Tables and structured references, or named ranges with OFFSET functions. For example:
=TODAY()-30 for "last 30 days" or =EOMONTH(TODAY(),-1)+1 for "first day of current month".