Excel Date Difference Calculator
Calculate the exact difference between today and any other date in days, months, or years
Comprehensive Guide: Calculate Date Differences in Excel
Calculating the difference between dates is one of the most common tasks in Excel, whether you’re tracking project timelines, calculating ages, or analyzing financial data. This expert guide covers everything you need to know about date calculations in Excel, including advanced techniques and real-world applications.
Understanding Excel’s Date System
Excel stores dates as sequential serial numbers called date values. Here’s how it works:
- January 1, 1900 is stored as serial number 1
- Each subsequent day increments by 1 (January 2, 1900 = 2)
- Time is stored as fractional portions of a day (12:00 PM = 0.5)
- Negative numbers represent dates before 1900 (not supported in Windows Excel)
Basic Date Difference Functions
1. Simple Subtraction Method
The most straightforward way to calculate date differences is by subtracting one date from another:
=End_Date - Start_Date
This returns the number of days between two dates. Format the result cell as “General” to see the numeric value.
2. DATEDIF Function (Most Powerful)
The DATEDIF function is Excel’s most versatile date calculator:
=DATEDIF(start_date, end_date, unit)
Where unit can be:
"d"– Complete days between dates"m"– Complete months between dates"y"– Complete years between dates"ym"– Months remaining after complete years"yd"– Days remaining after complete years"md"– Days remaining after complete months
| Function | Example | Result | Description |
|---|---|---|---|
| =DATEDIF(“1/1/2020″,”1/1/2023″,”y”) | Dates: 01/01/2020 to 01/01/2023 | 3 | Complete years between dates |
| =DATEDIF(“1/1/2020″,”6/15/2023″,”m”) | Dates: 01/01/2020 to 06/15/2023 | 41 | Complete months between dates |
| =DATEDIF(“1/1/2020″,”6/15/2023″,”d”) | Dates: 01/01/2020 to 06/15/2023 | 1256 | Total days between dates |
| =DATEDIF(“1/1/2020″,”6/15/2023″,”ym”) | Dates: 01/01/2020 to 06/15/2023 | 5 | Months remaining after complete years |
Advanced Date Calculations
1. DAYS360 Function (Financial Calculations)
The DAYS360 function calculates days between dates based on a 360-day year (12 months of 30 days each), commonly used in accounting:
=DAYS360(start_date, end_date, [method])
The optional method parameter:
FALSEor omitted: US method (30/360)TRUE: European method
2. NETWORKDAYS (Business Days Only)
Calculate working days excluding weekends and optional holidays:
=NETWORKDAYS(start_date, end_date, [holidays])
Example with holidays:
=NETWORKDAYS("1/1/2023", "12/31/2023", {"1/1/2023","12/25/2023"})
3. YEARFRAC (Fractional Years)
Calculate the fraction of a year between two dates:
=YEARFRAC(start_date, end_date, [basis])
Common basis values:
0or omitted: US (NASD) 30/3601: Actual/actual2: Actual/3603: Actual/3654: European 30/360
Practical Applications
1. Age Calculation
To calculate someone’s age in years, months, and days:
=DATEDIF(birth_date, TODAY(), "y") & " years, " & DATEDIF(birth_date, TODAY(), "ym") & " months, " & DATEDIF(birth_date, TODAY(), "md") & " days"
2. Project Timeline Tracking
Track days remaining until project completion:
=MAX(0, end_date - TODAY())
Format as number with 0 decimal places.
3. Contract Expiration Alerts
Create conditional formatting to highlight contracts expiring within 30 days:
- Select your date column
- Go to Home > Conditional Formatting > New Rule
- Use formula:
=AND(A1TODAY()) - Set your highlight color
Common Errors and Solutions
| Error | Cause | Solution |
|---|---|---|
| #VALUE! | Non-date values in formula | Ensure both arguments are valid dates or date serial numbers |
| #NUM! | Start date after end date | Swap the dates or use ABS function: =ABS(end_date-start_date) |
| Incorrect results | Cell formatted as text | Change format to Date or use DATEVALUE function |
| ###### | Column too narrow | Widen column or change number format |
Excel vs. Other Tools
While Excel is powerful for date calculations, here’s how it compares to other tools:
| Feature | Excel | Google Sheets | Python (pandas) | JavaScript |
|---|---|---|---|---|
| Basic date subtraction | Yes (returns days) | Yes (returns days) | Yes (Timedelta) | Yes (Date objects) |
| Business days calculation | NETWORKDAYS function | NETWORKDAYS function | bdate_range() | Custom function needed |
| 360-day year calculations | DAYS360 function | DAYS360 function | Custom calculation | Custom calculation |
| Time zone support | Limited | Limited | Excellent (timezone-aware) | Excellent (Date objects) |
| Historical date support | Limited (post-1900) | Better (supports pre-1900) | Excellent | Excellent |
Best Practices for Date Calculations
- Always use cell references instead of hardcoding dates in formulas
- Validate date entries using Data Validation (Data > Data Validation)
- Use consistent date formats throughout your workbook
- Document your formulas with comments for complex calculations
- Test edge cases like leap years and month-end dates
- Consider time zones if working with international data
- Use helper columns for intermediate calculations in complex formulas
Authoritative Resources
For official documentation and advanced techniques, consult these authoritative sources:
- Microsoft Office Support: DATEDIF Function – Official documentation with examples
- Corporate Finance Institute: DAYS360 Function Guide – Financial applications of date functions
- IRS Publication 538 (PDF) – Accounting periods and methods (see Section 3 for date calculations)
Frequently Asked Questions
Why does Excel show ###### in my date cells?
This typically indicates either:
- The column isn’t wide enough to display the date format (widen the column)
- The cell contains a negative date value (Excel can’t display dates before 1/1/1900 in Windows)
How do I calculate someone’s age in Excel?
Use this formula combination:
=DATEDIF(birth_date, TODAY(), "y") & " years, " & DATEDIF(birth_date, TODAY(), "ym") & " months, " & DATEDIF(birth_date, TODAY(), "md") & " days"
Can Excel handle dates before 1900?
In Windows versions of Excel, dates before January 1, 1900 aren’t supported. Mac versions of Excel do support dates back to January 1, 1904. For historical date calculations, consider:
- Using text representations of dates
- Switching to Google Sheets which has better pre-1900 support
- Using a programming language like Python for historical date math
Why does DATEDIF sometimes give different results than simple subtraction?
The DATEDIF function counts complete intervals between dates, while simple subtraction gives the total days. For example:
=DATEDIF("1/31/2023","2/1/2023","m")returns 0 (not a complete month)="2/1/2023"-"1/31/2023"returns 1 (day difference)
How do I calculate the number of weekdays between two dates?
Use the NETWORKDAYS function:
=NETWORKDAYS(start_date, end_date, [holidays])
To exclude specific weekdays (like making Saturday a workday), use NETWORKDAYS.INTL:
=NETWORKDAYS.INTL(start_date, end_date, [weekend], [holidays])
Where weekend is a number representing which days are weekends (1=Sat/Sun, 2=Sun/Mon, etc.)