How To Calculate Number Of Days In Excel

Excel Days Calculator

Calculate the number of days between two dates in Excel with different methods. Get instant results and visualizations.

Comprehensive Guide: How to Calculate Number of Days in Excel

Calculating the number of days between dates is one of the most common tasks in Excel, whether you’re tracking project timelines, calculating employee tenure, or analyzing financial periods. This expert guide covers all methods to calculate days in Excel, from basic to advanced techniques.

1. Basic Days Calculation (Simple Subtraction)

The simplest way to calculate days between two dates is by subtracting 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 exact number of days.

=End_Date – Start_Date

Example: =B2-A2

Key Points:

  • Returns the total number of days including weekends and holidays
  • Result is a number that can be formatted as “General” or “Number”
  • Works in all versions of Excel (2007 and later)

2. Calculating Workdays (Excluding Weekends)

For business calculations where you need to exclude weekends (Saturday and Sunday), use the NETWORKDAYS function:

=NETWORKDAYS(Start_Date, End_Date)

Example: =NETWORKDAYS(A2, B2)

Advanced Usage:

To also exclude specific holidays, add a range containing holiday dates as the third argument:

=NETWORKDAYS(A2, B2, D2:D10)

Where D2:D10 contains your list of holiday dates.

3. Calculating Days Excluding Both Weekends and Holidays

For complete business day calculations that exclude both weekends and company holidays:

=NETWORKDAYS(A2, B2, Holidays_Range) – 1

The “-1” adjustment accounts for the fact that NETWORKDAYS counts both the start and end dates as full days if they’re workdays.

4. Calculating Days Between Dates in Different Years

When working with dates spanning multiple years, you might want to break down the calculation:

=DATEDIF(Start_Date, End_Date, “y”) & ” years, ” & DATEDIF(Start_Date, End_Date, “ym”) & ” months, ” & DATEDIF(Start_Date, End_Date, “md”) & ” days”

Note: DATEDIF is a legacy function but remains one of the most powerful for complex date calculations.

5. Handling Time Components in Date Calculations

When your dates include time values, use INT to get whole days:

=INT(End_DateTime – Start_DateTime)

To get the remaining time after whole days:

=MOD(End_DateTime – Start_DateTime, 1)

6. Calculating Days Until Today

For dynamic calculations that always show days until the current date:

=TODAY() – Start_Date

Or for workdays until today:

=NETWORKDAYS(Start_Date, TODAY())

Excel Version Comparisons for Date Functions

The availability and behavior of date functions can vary slightly between Excel versions. Here’s a comparison of key date functions across versions:

Function Excel 2016 Excel 2019 Excel 2021/365 Excel Online
DATEDIF ✓ (undocumented) ✓ (undocumented) ✓ (undocumented) ✓ (undocumented)
NETWORKDAYS
NETWORKDAYS.INTL
DAYS
DAYS360
YEARFRAC
EDATE
EOMONTH

Common Errors and Solutions

Even experienced Excel users encounter issues with date calculations. Here are the most common problems and their solutions:

  1. #VALUE! Error

    Cause: One or both date arguments aren’t recognized as valid dates.

    Solution: Ensure cells are formatted as dates (Format Cells > Date) or use the DATE function to create proper dates.

  2. Negative Numbers

    Cause: Start date is after the end date.

    Solution: Use ABS function to get absolute value: =ABS(End_Date – Start_Date)

  3. Incorrect Holiday Exclusion

    Cause: Holiday range in NETWORKDAYS contains non-date values.

    Solution: Verify all cells in holiday range are proper dates.

  4. Leap Year Issues

    Cause: February 29 in non-leap years causing errors.

    Solution: Use DATE function to validate dates: =DATE(YEAR,2,29) will auto-correct to March 1 in non-leap years.

  5. Time Zone Problems

    Cause: Dates entered with time zones causing unexpected results.

    Solution: Use INT function to remove time components: =INT(End_Date) – INT(Start_Date)

Advanced Techniques for Date Calculations

1. Calculating Business Hours Between Dates

For precise business hour calculations (e.g., 9 AM to 5 PM):

=(NETWORKDAYS(A2,B2) – 1) * (End_Time – Start_Time) + IF(NETWORKDAYS(B2,B2), MEDIAN(B2, End_Time, Start_Time) – MEDIAN(A2, End_Time, Start_Time), 0)

Where A2 = start date/time, B2 = end date/time, and you’ve defined named ranges for Start_Time (9:00) and End_Time (17:00).

2. Creating a Dynamic Date Counter

For a counter that updates automatically:

=”Days remaining: ” & TODAY() – A2

Combine with conditional formatting to highlight when dates are approaching.

3. Calculating Age in Years, Months, and Days

For precise age calculations:

=DATEDIF(A2, TODAY(), “y”) & ” years, ” & DATEDIF(A2, TODAY(), “ym”) & ” months, ” & DATEDIF(A2, TODAY(), “md”) & ” days”

4. Working with Fiscal Years

For organizations with non-calendar fiscal years (e.g., July-June):

=IF(MONTH(End_Date)>=7, YEAR(End_Date)+1, YEAR(End_Date)) – IF(MONTH(Start_Date)>=7, YEAR(Start_Date), YEAR(Start_Date)-1)

Best Practices for Date Calculations in Excel

  1. Always Validate Dates

    Use ISNUMBER with DATEVALUE to check if entries are valid dates:

    =IF(ISNUMBER(DATEVALUE(A2)), “Valid”, “Invalid”)
  2. Use Named Ranges for Holidays

    Create a named range for your holiday list to make formulas more readable and maintainable.

  3. Document Your Formulas

    Add comments to complex date calculations to explain their purpose.

  4. Test with Edge Cases

    Always test with:

    • Same start and end dates
    • Dates spanning year boundaries
    • Leap day (February 29)
    • Dates with time components

  5. Consider Time Zones for Global Workbooks

    For international workbooks, either:

    • Standardize on UTC
    • Add time zone conversion columns
    • Use the =NOW() function with time zone adjustments

Excel Date Functions Reference

Function Purpose Syntax Example
TODAY Returns current date =TODAY() =TODAY()
NOW Returns current date and time =NOW() =NOW()
DATE Creates date from year, month, day =DATE(year,month,day) =DATE(2023,12,25)
YEAR Returns year from date =YEAR(date) =YEAR(A2)
MONTH Returns month from date =MONTH(date) =MONTH(A2)
DAY Returns day from date =DAY(date) =DAY(A2)
DATEDIF Calculates difference between dates =DATEDIF(start,end,unit) =DATEDIF(A2,B2,”d”)
NETWORKDAYS Workdays between dates =NETWORKDAYS(start,end,[holidays]) =NETWORKDAYS(A2,B2)
WORKDAY Returns workday before/after date =WORKDAY(start,days,[holidays]) =WORKDAY(A2,10)
EDATE Returns date n months before/after =EDATE(start,months) =EDATE(A2,3)
EOMONTH Returns last day of month =EOMONTH(start,months) =EOMONTH(A2,0)
WEEKDAY Returns day of week =WEEKDAY(date,[return_type]) =WEEKDAY(A2,2)
WEEKNUM Returns week number =WEEKNUM(date,[return_type]) =WEEKNUM(A2,21)
DAYS Days between dates =DAYS(end,start) =DAYS(B2,A2)
DAYS360 Days between dates (360-day year) =DAYS360(start,end,[method]) =DAYS360(A2,B2)
YEARFRAC Fraction of year between dates =YEARFRAC(start,end,[basis]) =YEARFRAC(A2,B2,1)

External Resources and Further Learning

For official documentation and advanced techniques, consult these authoritative sources:

Frequently Asked Questions

Why does Excel show ###### instead of my date?

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 01, 2023”).

How does Excel store dates internally?

Excel for Windows uses a date system where January 1, 1900 is day 1 (though it incorrectly assumes 1900 was a leap year). Excel for Mac originally used January 1, 1904 as day 0, but modern versions default to the 1900 system for compatibility.

Can I calculate days excluding specific weekdays (like Fridays)?

Yes, use NETWORKDAYS.INTL with a custom weekend parameter:

=NETWORKDAYS.INTL(Start_Date, End_Date, 11, Holidays)

Where “11” represents Saturday and Sunday as weekends (1=Saturday, 1=Sunday in binary). For different combinations, use different numbers (e.g., 13 for Sunday and Monday).

Why do I get different results between Excel and other programs?

Differences usually stem from:

  • Different date systems (1900 vs 1904 origin)
  • Time zone handling
  • Leap year calculations (Excel considers 1900 a leap year incorrectly)
  • Different day count conventions (30/360 vs actual/actual)

How can I calculate the number of months between dates?

Use DATEDIF with “m” unit:

=DATEDIF(Start_Date, End_Date, “m”)

For complete months (ignoring partial months):

=DATEDIF(Start_Date, End_Date, “m”) – IF(DAY(End_Date)

Leave a Reply

Your email address will not be published. Required fields are marked *