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 covers all the methods, formulas, and advanced techniques you need to master date calculations in Excel.
Why Date Calculations Matter in Excel
Date calculations form the backbone of many business processes:
- Project Management: Track durations between milestones
- HR Operations: Calculate employee tenure or vacation accrual
- Finance: Determine interest periods or payment schedules
- Inventory Management: Monitor product shelf life or expiration dates
- Data Analysis: Calculate time between events in datasets
Understanding Excel’s Date System
Excel stores dates as sequential serial numbers called date-time serial numbers:
- January 1, 1900 = 1 (Windows) or January 1, 1904 = 0 (Mac default)
- Each subsequent day increments by 1
- Times are stored as fractional portions of a day (0.5 = 12:00 PM)
This system allows Excel to perform arithmetic operations on dates just like numbers.
Basic Methods to Calculate Days Between Dates
Method 1: Simple Subtraction
The most straightforward approach is to subtract the earlier date from the later date:
=End_Date - Start_Date
Example: If cell A2 contains 5/15/2023 and B2 contains 6/20/2023:
=B2-A2
Result: 36 (days)
| Formula | Description | Example | Result |
|---|---|---|---|
| =B2-A2 | Basic date subtraction | 6/20/2023 – 5/15/2023 | 36 |
| =DATE(2023,6,20)-DATE(2023,5,15) | Using DATE function | Same as above | 36 |
| =TODAY()-A2 | Days from past date to today | TODAY()-5/15/2023 | Varies |
Method 2: DATEDIF Function
The DATEDIF function (Date + Difference) is Excel’s hidden gem for date calculations:
=DATEDIF(start_date, end_date, unit)
Units available:
"d"– Complete days between dates"m"– Complete months between dates"y"– Complete years between dates"ym"– Months excluding years"yd"– Days excluding years"md"– Days excluding months and years
Example: Calculate years, months, and days between 3/15/2020 and 6/20/2023:
=DATEDIF(A2,B2,"y") & " years, " &
DATEDIF(A2,B2,"ym") & " months, " &
DATEDIF(A2,B2,"md") & " days"
Result: “3 years, 3 months, 5 days”
Method 3: DAYS Function (Excel 2013+)
The DAYS function provides a simple way to calculate days between dates:
=DAYS(end_date, start_date)
Example: =DAYS("6/20/2023", "5/15/2023") returns 36
Method 4: DAYS360 Function
Used in accounting to calculate interest based on a 360-day year:
=DAYS360(start_date, end_date, [method])
Methods:
FALSEor omitted: US (NASD) method (default)TRUE: European method
| Method | US (NASD) | European |
|---|---|---|
| Start date is 31st | Becomes 30th | Becomes 30th |
| End date is 31st | Becomes 30th if start ≤ 30 | Always becomes 30th |
| February | Always 30 days | Always 30 days |
Advanced Date Calculations
Calculating Weekdays Only (Excluding Weekends)
Use the NETWORKDAYS function to exclude Saturdays and Sundays:
=NETWORKDAYS(start_date, end_date, [holidays])
Example: Calculate workdays between 5/15/2023 and 6/20/2023:
=NETWORKDAYS("5/15/2023", "6/20/2023")
Result: 26 weekdays
To include holidays as excluded days, reference a range containing holiday dates:
=NETWORKDAYS(A2, B2, Holidays!A2:A10)
Calculating Workdays with Custom Weekends
For non-standard weekends (e.g., Friday-Saturday in some Middle Eastern countries), use NETWORKDAYS.INTL:
=NETWORKDAYS.INTL(start_date, end_date, [weekend], [holidays])
Weekend number codes:
- 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
Adding or Subtracting Days from a Date
To project dates forward or backward:
=start_date + days
Example: What date is 90 days after 5/15/2023?
=DATE(2023,5,15) + 90
Result: 8/13/2023
For workdays only, use WORKDAY:
=WORKDAY(start_date, days, [holidays])
Example: What is the workday 10 workdays after 5/15/2023?
=WORKDAY("5/15/2023", 10)
Result: 5/31/2023
Common Date Calculation Scenarios
Scenario 1: Age Calculation
Calculate exact age in years, months, and days:
=DATEDIF(birth_date, TODAY(), "y") & " years, " &
DATEDIF(birth_date, TODAY(), "ym") & " months, " &
DATEDIF(birth_date, TODAY(), "md") & " days"
Scenario 2: Days Until Deadline
Calculate remaining days until a project deadline:
=deadline_date - TODAY()
Format as General to see negative numbers if deadline has passed.
Scenario 3: Fiscal Year Calculations
Many companies use fiscal years that don’t align with calendar years. To calculate days in a fiscal year (e.g., July 1 to June 30):
=MAX(0, MIN(end_date, fiscal_year_end) - MAX(start_date, fiscal_year_start) + 1)
Scenario 4: Date Differences in Pivot Tables
To analyze date differences in PivotTables:
- Add your data to the PivotTable
- Create a calculated field with your date difference formula
- Group by time periods if needed
Handling Common Date Calculation Errors
Error 1: #VALUE! Error
Causes and solutions:
- Non-date values: Ensure both arguments are valid dates
- Text that looks like dates: Use DATEVALUE() to convert
- Blank cells: Use IFERROR() or ISNUMBER() checks
Error 2: Negative Results
Occurs when start date is after end date. Solutions:
- Use ABS() to get absolute value:
=ABS(end_date - start_date) - Add validation to ensure proper date order
- Use IF to handle both scenarios:
=IF(end_date>start_date, end_date-start_date, start_date-end_date)
Error 3: Incorrect Leap Year Calculations
Excel handles leap years automatically, but be aware:
- February 29 exists only in leap years (divisible by 4, except century years not divisible by 400)
- DAYS360 always treats February as 30 days
- For precise calculations, use standard date subtraction
Excel vs. Other Tools for Date Calculations
| Feature | Excel | Google Sheets | Python (pandas) | JavaScript |
|---|---|---|---|---|
| Basic date subtraction | Yes (A1-B1) | Yes (A1-B1) | Yes (df[‘end’] – df[‘start’]) | Yes (new Date(end) – new Date(start)) |
| Weekday calculations | NETWORKDAYS() | NETWORKDAYS() | pd.bdate_range() | Custom function needed |
| Fiscal year support | Manual formulas | Manual formulas | pd.Period() with custom freq | Library needed |
| Leap year handling | Automatic | Automatic | Automatic | Automatic |
| Holiday exclusion | NETWORKDAYS() with range | NETWORKDAYS() with range | CustomBusinessDay() | Library needed |
| Large dataset performance | Slower with complex formulas | Slower with complex formulas | Very fast | Fast |
Best Practices for Date Calculations in Excel
- Always use date functions: Prefer DATE(), YEAR(), MONTH(), DAY() over text manipulation
- Store dates as dates: Never store dates as text (e.g., “05/15/2023”)
- Use consistent formats: Apply the same date format throughout your workbook
- Handle time zones carefully: Excel doesn’t natively handle time zones – convert to UTC if needed
- Document your formulas: Add comments for complex date calculations
- Test edge cases: Verify with leap years, month-end dates, and holidays
- Consider performance: For large datasets, minimize volatile functions like TODAY()
- Use named ranges: For holiday lists or frequently used date ranges
Automating Date Calculations with VBA
For repetitive tasks, consider creating custom VBA functions:
Function DaysBetween(startDate As Date, endDate As Date, Optional includeWeekends As Boolean = True) As Long
If includeWeekends Then
DaysBetween = endDate - startDate
Else
' Custom weekday calculation logic
DaysBetween = Application.WorksheetFunction.NetWorkdays(startDate, endDate)
End If
End Function
Call it from your worksheet like any other function: =DaysBetween(A2, B2, FALSE)
Real-World Applications and Case Studies
Case Study 1: Project Management
A construction company used Excel to:
- Track project timelines with Gantt charts
- Calculate buffer days between phases
- Automate delay notifications when milestones slipped
- Result: 22% reduction in project overruns
Case Study 2: HR Benefits Calculation
A multinational corporation implemented:
- Automated vacation accrual based on tenure
- Dynamic calculations for sabbatical eligibility
- Integration with payroll systems
- Result: 40% reduction in benefits calculation errors
Case Study 3: Financial Services
An investment bank developed:
- Excel models for bond accrual calculations
- Automated day count conventions (30/360, Actual/365)
- Interest payment scheduling tools
- Result: 95% faster deal structuring
External Resources and Further Learning
For official documentation and advanced techniques:
- Microsoft DATEDIF Function Documentation
- NIST Time and Frequency Division (Leap Seconds)
- IRS Publication 538 (Accounting Periods and Methods)
For academic research on temporal calculations: