How to Count Days Between Dates in Excel: The Complete 2026 Guide to DATEDIF, NETWORKDAYS, and Date Subtraction Formulas
Learn how to count days in excel between two dates using DATEDIF, NETWORKDAYS, and subtraction. Step-by-step formulas, examples, and troubleshooting tips.

Learning how to count days in excel between two dates is one of the most practical spreadsheet skills you can master, whether you are tracking project deadlines, calculating employee tenure, measuring invoice aging, or building a financial model. Excel offers several built-in methods to handle date arithmetic, each suited to a different scenario. The simplest approach is direct subtraction, while more advanced functions like DATEDIF and NETWORKDAYS handle business days, months, and years with surgical precision. This guide walks through every reliable technique used by analysts in 2026.
The core concept behind date math in Excel is that every date is stored internally as a sequential serial number. January 1, 1900 is serial number 1, and every day after that increments by exactly one. That means when you subtract one date cell from another, Excel returns the raw number of days between them as a plain integer. This system is the foundation of every date formula, and understanding it removes most of the confusion beginners run into when their results show strange dates instead of numbers.
Most users start with simple subtraction because it requires no functions at all. If cell A1 contains 1/1/2026 and cell B1 contains 3/15/2026, then the formula =B1-A1 returns 73, meaning 73 days separate those two dates. The trick is making sure the result cell is formatted as a Number rather than a Date. Excel often inherits date formatting from the source cells and displays the answer as a strange date like 3/14/1900, which is actually serial number 73 displayed as a calendar value.
When you need more control, the DATEDIF function shines. DATEDIF is technically a legacy function inherited from Lotus 1-2-3, but Microsoft still supports it in every modern version of Excel and Excel for the web. It takes three arguments: a start date, an end date, and a unit indicator like "d" for days, "m" for months, or "y" for years. The syntax =DATEDIF(A1,B1,"d") returns the same 73-day result, but DATEDIF can also calculate completed months and years, which subtraction cannot do cleanly.
Business users often need to count only working days, excluding weekends and holidays. That is where NETWORKDAYS and its more flexible cousin NETWORKDAYS.INTL come in. These functions ignore Saturday and Sunday by default and let you pass a list of holiday dates as an optional third argument. If you are calculating a 30-day payment term that should fall on a business day, NETWORKDAYS gives you a defensible, audit-ready number that aligns with how finance teams actually operate.
Beyond the basics, Excel supports date math inside conditional formulas, pivot tables, and array contexts. You can combine date counting with IF, SUMPRODUCT, and FILTER to build dashboards that age accounts receivable, flag overdue tasks, or compute average response times. The same techniques apply across Microsoft 365, Excel 2024, and the web version, though some functions like LAMBDA-based date calculators only work in modern releases. By the end of this article you will have a complete toolkit for every date counting scenario you encounter.
Before diving deeper, it helps to bookmark a broader formula reference so you can cross-check related functions like EOMONTH, WORKDAY, and EDATE that complement the day-counting toolkit. Date math rarely lives in isolation; you will usually combine it with text functions, lookups, and conditional logic to produce a finished report or model that stakeholders trust.
Counting Days in Excel by the Numbers

Five Ways to Count Days Between Dates
The fastest method. Subtract the earlier date from the later date using =B1-A1. Format the result cell as a number. Works in every version of Excel and returns calendar days including weekends.
Modern equivalent of subtraction with explicit syntax. Use =DAYS(end_date, start_date) to return calendar days. Available in Excel 2013 and later, plus Excel for Microsoft 365 and the web version.
Legacy but powerful. Use =DATEDIF(start, end, "d") for days, "m" for months, or "y" for years. The only built-in way to count completed months and years between two dates.
Counts working days only, automatically excluding Saturdays and Sundays. Add a holiday range as the third argument to skip company-specific days off. Ideal for payment terms and project planning.
International variant that lets you redefine which days are weekends. Use code 11 for Sunday only, 7 for Friday and Saturday (Middle East), or a binary string for custom patterns like a four-day week.
The simplest way to count days between two dates is direct subtraction. Type a start date in cell A1, for example 1/1/2026, and an end date in B1, such as 12/31/2026. In C1, enter =B1-A1 and press Enter. Excel will return 364, the exact number of calendar days separating the two values. If Excel shows a date instead of a number, click cell C1, press Ctrl+1 to open Format Cells, choose Number, and set decimals to 0. The math is correct; only the display format needs adjustment.
Order matters when subtracting. If you reverse the formula to =A1-B1, you get -364 because Excel returns a negative integer when the first date is later than the second. In a finance model this is useful for days-until-due calculations, but in most reports you want the absolute value. Wrap the subtraction with ABS to force a positive result: =ABS(B1-A1) always returns 364 regardless of input order, which prevents confusing negative numbers from polluting dashboards.
The DAYS function, introduced in Excel 2013, offers a clearer alternative. The syntax =DAYS(end_date, start_date) makes the calculation intention explicit and reads more naturally to a reviewer. Like subtraction, it returns calendar days including weekends and holidays. DAYS also accepts text strings representing dates, so =DAYS("12/31/2026","1/1/2026") works without needing actual date cells. This is handy when prototyping a formula or testing logic without populating a worksheet first.
For typed dates inside formulas, always enclose them in quotes and use a format Excel recognizes for your regional settings. In the US, that means MM/DD/YYYY format. If you live in a region using DD/MM/YYYY, the same text could be misinterpreted. To avoid ambiguity, use the DATE function to construct dates explicitly: =DAYS(DATE(2026,12,31), DATE(2026,1,1)) is unambiguous and portable across regions, which is critical for shared workbooks and templates distributed across teams.
Subtraction and DAYS both include weekends. If your goal is to count only weekdays, you need NETWORKDAYS instead. The syntax =NETWORKDAYS(A1, B1) returns the number of Monday through Friday days in the range, excluding the two weekend days each week. For the full 2026 calendar year that returns 261 working days, compared to 365 calendar days. The difference of 104 represents the 52 weekends in the year, which matches what most payroll and project schedulers expect.
If your organization observes specific holidays, list them in a separate column and pass that range as the third argument. For example, place ten US federal holiday dates in F1:F10, then use =NETWORKDAYS(A1, B1, F1:F10) to subtract those days from the working-day count. The function is smart enough to ignore holidays that fall on weekends, so you do not double-count. This approach matches the way HR and finance teams calculate paid time off accruals and vendor payment deadlines.
To make these formulas reusable, place start and end dates in named cells like StartDate and EndDate, then write =NETWORKDAYS(StartDate, EndDate, Holidays). Named ranges make formulas self-documenting and reduce errors when you copy them across worksheets. Combined with structured tables, named ranges turn ad-hoc spreadsheets into maintainable tools that survive being passed between team members without breaking.
DATEDIF, NETWORKDAYS, and DAYS Function Reference
DATEDIF takes three arguments: =DATEDIF(start_date, end_date, unit). The unit code controls the output: "d" returns total days, "m" returns completed months, "y" returns completed years, "md" returns days ignoring months and years, "ym" returns months ignoring years, and "yd" returns days ignoring years. For example, =DATEDIF("1/1/2020","6/15/2026","y") returns 6, while "m" returns 77 and "d" returns 2357. The function is undocumented in modern Excel help files but remains fully supported.
One critical quirk: DATEDIF requires the start date to be earlier than the end date, otherwise it returns a #NUM! error rather than a negative value. Wrap inputs with MIN and MAX to guarantee correct ordering: =DATEDIF(MIN(A1,B1), MAX(A1,B1), "d"). DATEDIF excels at age calculations, tenure tracking, and contract duration reports where you need rounded year or month counts rather than raw day totals.

Subtraction vs DATEDIF: Which Should You Use?
- +Direct subtraction is the fastest and most intuitive method for counting calendar days
- +DATEDIF can return completed months and years, which subtraction cannot do cleanly
- +NETWORKDAYS handles weekends and holidays without manual calculation
- +DAYS function provides a clear, self-documenting alternative to bare subtraction
- +Date functions work consistently across Excel desktop, Excel for the web, and Excel mobile
- +Combining functions with named ranges produces maintainable, audit-friendly formulas
- −DATEDIF is undocumented in modern Excel help, which makes debugging harder for new users
- −Subtraction inherits date formatting and often displays results as confusing date strings
- −NETWORKDAYS includes both endpoints, which can cause off-by-one errors in deadline math
- −DATEDIF returns #NUM! errors when the start date is later than the end date
- −Mixed argument order across DATEDIF, NETWORKDAYS, and DAYS causes common bugs
- −Text-typed dates depend on regional settings and can produce unexpected results when shared
Day-Counting Formula Checklist
- ✓Confirm both cells contain real date values, not text that looks like a date
- ✓Set the result cell format to Number with zero decimals before evaluating the answer
- ✓Decide whether you need calendar days, working days, or completed months
- ✓Use ABS around subtraction when input order may vary in your data
- ✓Pass a holiday range to NETWORKDAYS for accurate business-day counts
- ✓Wrap DATEDIF inputs with MIN and MAX to avoid #NUM! errors on reversed dates
- ✓Use the DATE function inside formulas to make typed dates region-independent
- ✓Create named ranges like StartDate and EndDate for self-documenting formulas
- ✓Verify Excel options have not disabled the 1900 date system in favor of 1904
- ✓Test edge cases like leap years, month boundaries, and February 29 explicitly
Always test with a known interval
Before relying on a date formula in a report, validate it against a known interval. For example, January 1 to December 31 of any non-leap year should return 364 days from subtraction and 365 from DAYS plus one. The week of July 4 should return 4 working days in NETWORKDAYS with the holiday list applied. Building this kind of regression test into your workbook catches errors before they reach stakeholders.
Beyond the basic functions, real-world date math often involves edge cases that trip up otherwise careful analysts. Leap years are the most common pitfall. February 29 only exists every four years, with the exception of century years not divisible by 400. The year 2000 had a February 29 but 1900 and 2100 do not. Excel correctly handles this rule from 1900 onward, but your custom formulas must too. If you are computing ages or anniversaries, account for users born on February 29 by deciding whether their birthday falls on February 28 or March 1 in non-leap years.
Another scenario involves counting days across midnight when working with datetime values rather than pure dates. If A1 contains 1/1/2026 11:00 PM and B1 contains 1/2/2026 1:00 AM, subtraction returns 0.0833, representing two hours expressed as a fraction of a day. To extract whole days, use INT(B1)-INT(A1) which strips the time portion. To extract hours, multiply the fractional difference by 24. Mixing dates and times in the same column is a frequent source of confusing results and should be normalized before analysis.
For aging reports such as accounts receivable, you typically want to count days from each invoice date to today. The TODAY function returns the current date and updates every time the workbook recalculates. A formula like =TODAY()-InvoiceDate gives the age in days. To bucket invoices into 0-30, 31-60, 61-90, and 90+ day categories, nest the result inside an IF or use INDEX with a MATCH against a bucket lookup table. This pattern appears in nearly every finance dashboard and is worth memorizing.
When working with large datasets, array-aware formulas become invaluable. In modern Excel with dynamic arrays, you can apply a date difference across an entire column without dragging. For example, =B2:B1000-A2:A1000 spills the days between each pair of dates into the result column. This eliminates the need for individual cell formulas and improves performance in workbooks with thousands of rows. Combine it with FILTER or LET for sophisticated reporting without macros or Power Query.
Power Query offers an alternative for very large datasets or for repeatable ETL pipelines. The Date.From and Duration.Days functions in M language replicate Excel's date math but execute outside the workbook formula engine, so they do not slow down recalculation. If your data lives in a SharePoint list, SQL database, or CSV file refreshed daily, Power Query handles the date difference calculation during load rather than at every recalc, which dramatically improves performance on data refreshes.
Conditional date counting is another powerful pattern. Suppose you want to count how many entries in a list fall within the last 30 days. The formula =SUMPRODUCT((TODAY()-DateRange<=30)*1) returns the count efficiently without requiring a helper column. Similarly, =COUNTIFS(DateRange,">="&TODAY()-30,DateRange,"<="&TODAY()) works in older Excel versions and respects multiple criteria simultaneously, making it ideal for filtered counts on dashboards.
Finally, consider time zone awareness when sharing workbooks across global teams. Excel does not natively track time zones, so a meeting scheduled for 9:00 AM in one workbook could represent very different moments depending on the recipient's location. Best practice is to store dates and times in a single canonical zone, typically UTC, and convert for display only at the presentation layer. This keeps date math consistent regardless of where the file is opened.

Excel historically treats 1900 as a leap year even though it was not, in order to maintain compatibility with the original Lotus 1-2-3 date system. This means dates before March 1, 1900 are off by one day from the correct calendar. If your analysis involves pre-1900 dates, use a different tool or build a custom adjustment, because Excel will silently return wrong answers for that narrow range.
Troubleshooting date formulas usually comes down to three categories of errors: format mismatches, type mismatches, and logic errors. Format mismatches happen when your result cell inherits date formatting from the inputs. The fix is always to manually set the cell format to Number. Press Ctrl+1, choose Number from the category list, set decimals to 0, and click OK. If a result still shows as a date after this, the cell may have a custom format applied; clear it with Home tab, Clear, Clear Formats, then reapply your number format.
Type mismatches occur when one or both source cells contain text that looks like a date but is not stored as an actual date value. You can test by selecting the cell and looking at the right-aligned versus left-aligned display: real dates align right, text aligns left. Use DATEVALUE to convert text dates to real dates: =DATEVALUE(A1) returns the serial number, which you can then use in date math. Wrapping with DATEVALUE inside your formula like =DATEVALUE(B1)-DATEVALUE(A1) handles the conversion inline.
The #VALUE! error from a date subtraction almost always means one input is text or empty. Inspect each cell individually using ISNUMBER, since real dates return TRUE and text dates return FALSE. To prevent the error in production workbooks, wrap your formula with IFERROR: =IFERROR(B1-A1, "Check dates") displays a friendly message instead of an ugly error code. This is especially useful in templates distributed to non-technical users who may paste data from outside sources.
The #NUM! error from DATEDIF means the start date is later than the end date. As mentioned earlier, fix this with MIN and MAX wrappers, or with a conditional like =IF(A1<=B1, DATEDIF(A1,B1,"d"), DATEDIF(B1,A1,"d")). Some analysts prefer the explicit IF version because it documents the intent clearly for future readers. Either approach prevents the formula from crashing when dates arrive in arbitrary order from a database or pivot source.
Locale-related bugs are sneakier. A workbook built with US date conventions can break when opened in a region using DD/MM/YYYY. Inside formulas, always use the DATE function to construct values: =DATE(2026,6,15) is unambiguous everywhere, while "6/15/2026" in quotes may be misread as June 15 in the US or as nonsense in regions where the day must come first. For data imported from text files, use Power Query or Text to Columns with explicit date format selection to control the parsing.
If your workbook uses the 1904 date system, which is an option originally added for Mac compatibility, all serial numbers shift by exactly 1462 days. This is rarely a problem until you copy data between workbooks using different settings, at which point dates appear to jump four years. Check the setting under File, Options, Advanced, then under When calculating this workbook, look for Use 1904 date system. Standardize on the 1900 system unless you have a specific reason to do otherwise.
Finally, some users report that their date formulas return suspiciously round numbers like exactly 0 or exactly 30. This usually means automatic calculation is disabled. Press F9 to force a recalc, or check Formulas tab, Calculation Options, and ensure Automatic is selected. Cross-checking your day-count formulas alongside related functions referenced in any comprehensive formula guide will help confirm that the broader workbook is computing correctly rather than serving stale results.
To put everything together, here is a practical workflow you can apply to almost any date-counting task. Start by sketching what you want to know in plain English: am I counting calendar days, working days, or completed months? Is the goal a single number, a percentage, or a bucketed category? Writing this down forces clarity before you touch a formula. Many bugs originate from mismatched expectations between the analyst and the eventual user of the report, and a one-sentence requirement note eliminates the most common confusion at the start.
Once you know the goal, lay out the inputs in named cells or a structured table. A table with columns for StartDate, EndDate, Holidays, and Notes is more durable than scattered cells, because Excel automatically extends formulas to new rows. Apply explicit date formatting to those columns using Format Cells. This prevents text from sneaking in, which is the leading cause of #VALUE! errors. If your data arrives from an external source, run a Text to Columns step or a Power Query date conversion before any math touches it.
Choose the right function for the question. Use direct subtraction or the DAYS function for calendar days. Use NETWORKDAYS or NETWORKDAYS.INTL when weekends matter. Use DATEDIF for completed months or years, especially in HR and contract scenarios. Use YEARFRAC for proportional time calculations in finance. Document your choice in a comment so reviewers know why you picked that particular function. This habit pays off when you revisit the workbook months later and cannot remember the rationale.
Build in defensive checks. Wrap critical formulas with IFERROR to display a helpful message. Add data validation to date cells so users cannot type invalid values like 13/45/2026. Use conditional formatting to highlight rows where the end date precedes the start date or where required fields are blank. These guards cost a few minutes to add and save hours of debugging later. They also make your workbook safer to share with users who are not Excel experts and might otherwise produce incorrect results without realizing it.
Test with edge cases before declaring a workbook finished. Try a 0-day span where both dates are identical, a 1-day span across two adjacent days, a span that crosses a leap day, a span that lands on a weekend, and a span with a holiday inside it. Compare your formula's output to a manual count. If the numbers match, you can trust the formula. If they do not, fix the formula and document the fix so the next person reading your file understands what changed and why.
For large or recurring workbooks, consider promoting your date math into a LAMBDA function. Modern Excel supports user-defined functions written in formula syntax, so you can name a complex date calculation and reuse it cleanly. For example, define BusinessDaysWithHolidays as a LAMBDA over start, end, and holidays, then call it like a built-in. This abstraction makes the worksheet front end much easier to read while preserving the full calculation logic in one centralized definition that can be updated in one place.
Finally, document your date conventions in a hidden Notes or Readme sheet within the workbook. State which timezone, which date system (1900 vs 1904), which holiday calendar, and which counting convention apply. New team members can read this in 30 seconds and avoid weeks of confused debugging. Treating spreadsheets as small software systems with documentation, tests, and version control elevates them from one-off scratchpads into reliable, auditable tools that survive ownership changes and last for years.
Excel Questions and Answers
About the Author
Business Consultant & Professional Certification Advisor
Wharton School, University of PennsylvaniaKatherine Lee earned her MBA from the Wharton School at the University of Pennsylvania and holds CPA, PHR, and PMP certifications. With a background spanning corporate finance, human resources, and project management, she has coached professionals preparing for CPA, CMA, PHR/SPHR, PMP, and financial services licensing exams.