To calculate the number of days between two dates in Excel, the simplest method is to subtract the start date from the end date using a basic subtraction formula (e.g., =B1-A1). Excel treats dates as sequential serial numbers, so a simple mathematical subtraction provides the exact count of days between them.
What You'll Need
- Microsoft Excel installed on your computer (Desktop, Web, or Mobile versions).
- A dataset containing at least two dates formatted correctly as Date values.
- An understanding of basic cell referencing (e.g., knowing that A1 refers to the cell in column A, row 1).
Step-by-Step
- Prepare your data: Open your Excel spreadsheet and ensure your dates are in separate columns or cells. For example, place your start date in cell A2 and your end date in cell B2. To ensure Excel recognizes these as dates rather than plain text, select the cells and check the Number Format dropdown in the Home tab; it should say "Date."
- Select the result cell: Click on the empty cell where you want the number of days to appear (for example, cell C2).
- Enter the subtraction formula: Type the equals sign (=) to begin the formula. Then, click on the cell containing the end date (B2), type a minus sign (-), and click on the cell containing the start date (A2). Your formula should look like this:
=B2-A2. Press Enter. - Adjust the cell format: If the result looks like a strange date (e.g., 1/15/1900) instead of a number, Excel has automatically applied a Date format to your result cell. To fix this, go to the Home tab, look at the Number group, and change the dropdown menu from "Date" to "General" or "Number." This will reveal the actual number of days.
- Use the DAYS function (Alternative Method): If you prefer using a built-in function, click on your result cell and type
=DAYS(end_date, start_date). For our example, this would be=DAYS(B2, A2). Note that the order of arguments in the DAYS function is specific: the end date comes first, followed by the start date. - Use the DATEDIF function (Advanced Method): If you need more control (such as calculating only full months or years), use the DATEDIF function. Type
=DATEDIF(A2, B2, "d"). In this formula, the start date comes first, followed by the end date, and finally the unit "d" which tells Excel you want the result in days. - Apply to multiple rows: If you have a long list of dates, hover your mouse over the bottom-right corner of your result cell until you see a small black cross (the Fill Handle). Click and drag that cross down the column to apply the calculation to all subsequent rows automatically.
Common Mistakes
One of the most frequent errors occurs when Excel treats your dates as "Text" rather than "Date" values. If you type a date like "12.05.2026" but your system expects "05/12/2026," Excel may not recognize it as a number. When this happens, subtraction formulas will return a #VALUE! error because you cannot mathematically subtract words from words. Always ensure your dates are right-aligned in the cell by default; if they are left-aligned, Excel likely views them as text.
Another common mistake is the "Off-by-One" error. If you want to include both the start day and the end day in your total count (for example, counting the total duration of a project where both the first and last day are working days), a simple subtraction will be one day short. In this specific scenario, you must add one to your formula: =(B2-A2)+1.
Lastly, users often confuse the argument order in different functions. As mentioned in the steps, the DAYS function requires the end date first, while the DATEDIF function requires the start date first. Swapping these will result in a negative number, which can throw off your entire dataset if you are not expecting it.
Tips
To make your spreadsheet more professional, use the NETWORKDAYS function if you only want to count business days. This function automatically excludes weekends and can even exclude a custom list of holidays. The syntax is =NETWORKDAYS(start_date, end_date, [holidays]). You can list your holiday dates in a separate range of cells and reference that range in the third part of the formula.
If you are working with timestamps (dates that include hours, minutes, and seconds), a simple subtraction will return a decimal number. The whole number represents the days, and the decimal represents the fraction of the day. To get only the whole number of days, wrap your formula in the INT function, like this: =INT(B2-A2). This strips away the time component and leaves you with a clean integer.
For visual clarity, use Conditional Formatting to highlight rows where the difference between dates is zero or negative. This is helpful for spotting data entry errors where an end date was accidentally entered as occurring before a start date.
Troubleshooting
If your formula is not working as expected, follow these steps in order:
- Check for #VALUE! errors: This almost always means one of your cells contains text instead of a date. To test this, use the formula
=ISNUMBER(A2). If it returns FALSE, your date is actually text. You can fix this by using the "Text to Columns" feature under the Data tab to convert the text to date format, or by re-typing the dates using your system's standard format. - Check for negative numbers: If you see a negative result, your start date is actually later than your end date. Check your data entry or swap the cell references in your formula.
- Check for unexpected date formats: If your result looks like "01/01/1900," your cell is formatted as a Date. Change the cell format to "General" or "Number" in the Home tab.
- Check for hidden spaces: Sometimes data imported from web software contains invisible spaces before or after the date. Use the TRIM function to clean your data, for example:
=DATEVALUE(TRIM(A2)).
Frequently Asked Questions
How do I count only workdays between two dates?
Use the =NETWORKDAYS(start_date, end_date) function. This will automatically subtract Saturdays and Sundays from your total count.
Why does my result show a date instead of a number?
Excel is trying to be helpful by assuming the result of a date calculation should also be a date. You simply need to change the cell format to "General" or "Number" in the Home tab ribbon.
Can I calculate the difference in months instead of days?
Yes, use the DATEDIF function with the "m" unit: =DATEDIF(start_date, end_date, "m"). This will return the number of complete months between the two dates.
How do I calculate days between a date and today?
Use the TODAY function within your subtraction formula. For example, =TODAY()-A2 will tell you how many days have passed since the date in cell A2.
What is the difference between DAYS and DATEDIF?
The DAYS function is a modern, straightforward function specifically for counting days. DATEDIF is an older, "hidden" function used for more complex calculations like years, months, or specific day increments within a period.