Excel Practice Test

โ–ถ

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

๐Ÿ“…
1900
Excel Date Epoch
๐Ÿ”ข
2958465
Max Date Serial
โฑ๏ธ
7
Days in NETWORKDAYS Cycle
๐Ÿ“Š
6
DATEDIF Unit Codes
โœ…
3
Args in DATEDIF
Try Free Excel Questions on Counting Days Between Two Dates

Five Ways to Count Days Between Dates

โž– Direct Subtraction

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.

๐Ÿ“† DAYS Function

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.

๐Ÿ”„ DATEDIF Function

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.

๐Ÿ’ผ NETWORKDAYS

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.

๐ŸŒ NETWORKDAYS.INTL

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.

FREE Excel Basic and Advance Questions and Answers
Test your knowledge of dates, formulas, and core Excel skills with practice questions.
FREE Excel Formulas Questions and Answers
Practice DATEDIF, NETWORKDAYS, DAYS, and other date-related formula questions.

DATEDIF, NETWORKDAYS, and DAYS Function Reference

๐Ÿ“‹ DATEDIF

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.

๐Ÿ“‹ NETWORKDAYS

NETWORKDAYS counts business days between two dates. Syntax: =NETWORKDAYS(start_date, end_date, [holidays]). Saturday and Sunday are automatically excluded. The holidays argument is optional and accepts a single date, a range, or an array constant. The function includes both start and end dates in the count if they fall on weekdays, which is sometimes confusing. To exclude the start date, subtract one: =NETWORKDAYS(A1+1, B1).

NETWORKDAYS.INTL extends this with a weekend parameter. Use code 1 (or omit) for Saturday-Sunday, 2 for Sunday-Monday, 7 for Friday-Saturday, 11 for Sunday-only, 12 for Monday-only, and so on through 17. You can also pass a 7-character binary string like "0000011" where 1 indicates a weekend day. This flexibility supports international offices, retail schedules, and non-standard work weeks.

๐Ÿ“‹ DAYS and YEARFRAC

The DAYS function is the modern replacement for plain subtraction: =DAYS(end_date, start_date). Note the argument order is reversed from DATEDIF and NETWORKDAYS, which is a common source of bugs. DAYS always returns calendar days including weekends and holidays. It works in Excel 2013 and later. There is also a DAYS360 function that assumes every month has 30 days, used in certain bond accounting and finance scenarios where a standardized year of 360 days is the convention.

YEARFRAC returns the fraction of a year between two dates. =YEARFRAC(A1, B1) returns a decimal like 0.5041 for roughly half a year. The optional basis argument selects the day-count convention: 0 for 30/360 US, 1 for actual/actual, 2 for actual/360, 3 for actual/365, and 4 for 30/360 European. Multiply YEARFRAC by 365 to convert to approximate days, useful in interest accrual and pro-rata billing calculations.

Subtraction vs DATEDIF: Which Should You Use?

Pros

  • 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

Cons

  • 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
FREE Excel Functions Questions and Answers
Sharpen your knowledge of Excel functions including date, lookup, and logical operations.
FREE Excel MCQ Questions and Answers
Multiple-choice quiz covering Excel features, shortcuts, and formula concepts.

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.

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.

Practice Excel Formulas With Free Date and Function Questions

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.

FREE Excel Questions and Answers
Comprehensive Excel certification-style practice covering formulas, formatting, and analysis.
FREE Excel Trivia Questions and Answers
Fun Excel trivia covering shortcuts, history, hidden features, and lesser-known functions.

Excel Questions and Answers

What is the simplest way to count days between two dates in Excel?

The simplest method is direct subtraction. Place the start date in one cell and the end date in another, then in a third cell type =EndCell-StartCell and press Enter. If the result displays as a date, change the cell format to Number with zero decimals. This returns the exact number of calendar days between the two dates, including weekends, and works in every version of Excel from 2003 onward.

How do I count only business days excluding weekends?

Use the NETWORKDAYS function. The syntax is =NETWORKDAYS(start_date, end_date, [holidays]). The function automatically excludes Saturdays and Sundays. The third argument is optional and accepts a range of holiday dates that should also be skipped. For example, =NETWORKDAYS(A1, B1, F1:F10) counts working days between A1 and B1 while ignoring any holidays listed in F1 through F10.

Why does my date subtraction show as a date instead of a number?

Excel inherited the date format from the source cells. To fix this, click the result cell, press Ctrl+1 to open Format Cells, choose Number from the category list, set decimals to 0, and click OK. The underlying calculation is correct; only the display format is wrong. You can also use the Number Format dropdown on the Home tab and select Number directly without opening the dialog.

What does DATEDIF do that subtraction cannot?

DATEDIF can return completed months and years, not just days. The unit codes include "d" for days, "m" for complete months, "y" for complete years, "md" for days ignoring months and years, "ym" for months ignoring years, and "yd" for days ignoring years. This makes DATEDIF essential for age calculations, tenure tracking, and contract duration reporting where rounded month or year counts are required rather than raw day counts.

Why does DATEDIF give a #NUM! error?

DATEDIF returns #NUM! when the start date is later than the end date. Unlike subtraction, DATEDIF does not return negative values. To prevent the error, wrap your inputs with MIN and MAX: =DATEDIF(MIN(A1,B1), MAX(A1,B1), "d"). Alternatively, use an IF statement to detect which date is earlier and swap arguments accordingly. This ensures the formula always returns a valid positive number regardless of input order.

How do I count days from a specific date to today?

Use the TODAY function. The formula =TODAY()-A1 returns the number of days between the date in A1 and today's date. TODAY updates automatically every time the workbook recalculates, so the result stays current. To get the absolute value regardless of which date is later, wrap with ABS: =ABS(TODAY()-A1). For business days only, use =NETWORKDAYS(A1, TODAY()) instead of plain subtraction.

Can I count days excluding custom holidays?

Yes. Both NETWORKDAYS and NETWORKDAYS.INTL accept an optional holidays argument. List your company or country holidays in a column, then pass that range as the third argument. For example, =NETWORKDAYS(A1, B1, Holidays!A1:A20) excludes any of those dates from the count. The function is smart enough to ignore holidays that fall on weekends, so you never double-count and the result remains accurate.

What is the difference between DAYS and DATEDIF with the d option?

Both return the same calendar day count, but the argument order is reversed. DAYS takes end date first: =DAYS(end, start). DATEDIF takes start date first: =DATEDIF(start, end, "d"). DAYS works only in Excel 2013 and later, while DATEDIF works in every version. DAYS handles dates passed in either order gracefully, while DATEDIF returns #NUM! if the start date is later than the end date.

How do I count working days with a non-standard work week?

Use NETWORKDAYS.INTL with the weekend parameter. Pass a code like 7 for Friday-Saturday weekends, 11 for Sunday only, or a binary string like "0000011" where 1 indicates a non-working day. For a four-day work week of Monday through Thursday, use "0000111" to mark Friday, Saturday, and Sunday as non-working. This flexibility supports international teams, retail schedules, and any custom work pattern your organization follows.

How do I handle leap years in date calculations?

Excel handles leap years automatically in all built-in date functions, so subtraction, DAYS, DATEDIF, and NETWORKDAYS all return correct results across February 29. However, custom logic such as anniversary calculations must decide what happens for people born on February 29 in non-leap years. Most systems use February 28 or March 1 as the substitute. Document your choice and apply it consistently with an IF statement checking for February 29 dates.
โ–ถ Start Quiz