Excel Days Between Dates Calculator
Calculate the exact number of days between two dates using Excel formulas
Results:
Total Days: 0
Excel Formula: =DAYS(end_date, start_date)
Alternative Formula: =end_date - start_date
Complete Guide: Excel Formula to Calculate Days Between Two Dates
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, including handling weekends, holidays, and various edge cases.
Basic Methods to Calculate Days Between Dates
-
Simple Subtraction Method
The most straightforward way is to subtract the start date from the end date. Excel stores dates as serial numbers (days since January 1, 1900), so subtraction gives you the difference in days.
Formula:
=end_date - start_dateExample:
=B2-A2(where B2 contains the end date and A2 contains the start date) -
DAYS Function (Excel 2013 and later)
The DATEDIF function is specifically designed for date calculations and is more readable.
Formula:
=DAYS(end_date, start_date)Example:
=DAYS(B2, A2) -
DATEDIF Function (for complex calculations)
While primarily used for year/month/day differences, DATEDIF can also calculate total days.
Formula:
=DATEDIF(start_date, end_date, "d")Example:
=DATEDIF(A2, B2, "d")
When to Use Each Method
- Simple subtraction: Best for quick calculations in any Excel version
- DAYS function: Most readable, best for Excel 2013+
- DATEDIF: Useful when you also need years/months breakdown
Date Serial Numbers
Excel stores dates as sequential serial numbers called date-time code. January 1, 1900 is serial number 1, and each subsequent day increments by 1.
This is why date subtraction works – you’re actually subtracting these serial numbers.
Handling Weekends and Holidays
For business calculations where weekends and holidays shouldn’t be counted, use the NETWORKDAYS function:
Basic NETWORKDAYS: =NETWORKDAYS(start_date, end_date)
This excludes Saturdays and Sundays automatically.
With Custom Holidays: =NETWORKDAYS(start_date, end_date, holidays)
Where “holidays” is a range containing your holiday dates.
| Function | Counts Weekends? | Counts Holidays? | Excel Version |
|---|---|---|---|
| Simple subtraction | Yes | Yes | All |
| DAYS | Yes | Yes | 2013+ |
| DATEDIF | Yes | Yes | All |
| NETWORKDAYS | No | No (unless specified) | All |
| NETWORKDAYS.INTL | Customizable | No (unless specified) | 2010+ |
Advanced Date Calculations
For more complex scenarios, you can combine functions:
-
Days excluding specific weekdays:
Use NETWORKDAYS.INTL with weekend parameters. For example, to exclude only Sundays:
=NETWORKDAYS.INTL(start_date, end_date, 11)Where “11” is the weekend parameter (binary 1011 = Sunday only)
-
Partial days calculation:
If your dates include time components, the result will include fractional days. To get just whole days:
=INT(end_date - start_date) -
Date validation:
Always validate your dates with ISNUMBER:
=IF(ISNUMBER(start_date)*ISNUMBER(end_date), end_date-start_date, "Invalid date")
Common Errors and Solutions
| 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 cells contain valid dates |
| Negative number | End date is before start date | Check your date order or use ABS() function |
| Incorrect day count | Dates stored as text | Use DATEVALUE() to convert text to dates |
| 1900 date system issue | Dates before 1900 not supported | Use alternative date systems or manual calculation |
Real-World Applications
Project Management
- Calculate project duration
- Track milestones and deadlines
- Create Gantt charts
- Monitor task completion times
Human Resources
- Calculate employee tenure
- Track vacation accrual
- Monitor probation periods
- Calculate notice periods
Finance
- Calculate loan periods
- Track investment durations
- Monitor contract terms
- Calculate interest periods
Excel Date Functions Reference
| Function | Purpose | Syntax | Example |
|---|---|---|---|
| TODAY | Returns current date | =TODAY() | =TODAY() returns today’s date |
| NOW | Returns current date and time | =NOW() | =NOW() returns current datetime |
| DATE | Creates a date from year, month, day | =DATE(year, month, day) | =DATE(2023, 12, 25) returns 12/25/2023 |
| YEAR | Extracts year from date | =YEAR(date) | =YEAR(A2) returns year from cell A2 |
| MONTH | Extracts month from date | =MONTH(date) | =MONTH(A2) returns month from cell A2 |
| DAY | Extracts day from date | =DAY(date) | =DAY(A2) returns day from cell A2 |
| WEEKDAY | Returns day of week (1-7) | =WEEKDAY(date, [return_type]) | =WEEKDAY(A2) returns weekday number |
| WORKDAY | Adds workdays to date | =WORKDAY(start_date, days, [holidays]) | =WORKDAY(A2, 10) adds 10 workdays |
| EDATE | Returns date n months before/after | =EDATE(start_date, months) | =EDATE(A2, 3) adds 3 months |
| EOMONTH | Returns last day of month | =EOMONTH(start_date, months) | =EOMONTH(A2, 0) returns end of current month |
Best Practices for Date Calculations
-
Always use cell references
Avoid hardcoding dates in formulas. Reference cells instead for flexibility.
-
Format your dates consistently
Use the same date format throughout your workbook to avoid confusion.
-
Validate your dates
Use Data Validation to ensure only valid dates are entered.
-
Document your formulas
Add comments to complex date calculations to explain their purpose.
-
Test with edge cases
Check your formulas with:
- Dates spanning year boundaries
- Leap years (February 29)
- Dates before 1900 (if applicable)
- Same start and end dates
-
Consider time zones
If working with international dates, account for time zone differences.
-
Use named ranges
For frequently used date ranges, create named ranges for better readability.
Alternative Methods in Other Tools
Google Sheets
Google Sheets uses the same basic formulas as Excel:
=end_date - start_date=DAYS(end_date, start_date)=DATEDIF(start_date, end_date, "d")=NETWORKDAYS(start_date, end_date)
Google Sheets also supports the =TODAY() and =NOW() functions.
JavaScript
In JavaScript, you can calculate date differences with:
const diffTime = Math.abs(endDate - startDate);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
Where startDate and endDate are Date objects.
Python
Using Python’s datetime module:
from datetime import date
delta = end_date - start_date
days = delta.days
For business days, use the numpy or pandas libraries.
Frequently Asked Questions
-
Why does Excel show ###### instead of my date?
This typically means your column isn’t wide enough to display the date format. Either widen the column or change to a shorter date format (like “mm/dd/yy” instead of “mm/dd/yyyy”).
-
How do I calculate days between dates in different time zones?
Excel doesn’t natively handle time zones. You’ll need to:
- Convert both dates to the same time zone first
- Then perform your calculation
- Alternatively, use UTC times for both dates
-
Can I calculate days between dates before 1900?
Excel’s date system starts at January 1, 1900 (serial number 1). For dates before 1900:
- Use text representations and manual calculations
- Consider using a different tool for historical date calculations
- Some third-party Excel add-ins support pre-1900 dates
-
Why is my DATEDIF function returning #NUM! error?
This usually happens when:
- The start date is after the end date (use ABS for absolute value)
- Either date isn’t recognized as a valid date
- You’re using an invalid unit argument (must be “y”, “m”, “d”, “ym”, “yd”, or “md”)
-
How do I calculate only weekdays between two dates?
Use the NETWORKDAYS function:
=NETWORKDAYS(start_date, end_date)To exclude specific holidays, add them as a third argument:=NETWORKDAYS(start_date, end_date, holidays)Where “holidays” is a range containing your holiday dates.
Authoritative Resources
For more official information about date calculations in Excel, consult these authoritative sources:
-
Microsoft Official Documentation: DATEDIF Function
Comprehensive guide to the DATEDIF function directly from Microsoft.
-
NIST Time and Frequency Division
National Institute of Standards and Technology information on time measurement standards.
-
IRS Date and Time Rules
Official IRS guidelines on date calculations for tax purposes.