Placing date and time stamps into Excel is easy enough but sometimes you need to know the number of days, months, or years between two different dates. Researchers often do this to figure out how old a research subject was at a given point in time and financial calculations often involve analyzing money from different points in time.
Learn how to subtract dates in Excel to figure out the number of days, months, or years between two dates in your worksheet.
Number of Days
The most basic application for subtracting dates in Excel is when you need to know how many days there are between the two dates. Suppose you have two dates in Excel and you want to use the number for days between them in another calculation. In such a situation, you may have a worksheet that looks like this:

Suppose in cell A4 you want to calculate the number of days between these two dates. To do this, simply make the calculation as you would any other:
=B2-B1
This formula returns a value of 812 days between these two dates.

One problem you may run into when subtracting dates is if the first date in the formula occurs after the second date. In this case, Excel would return a negative number. If you only want to know the number of days between two dates without regard for which date is entered into the equation first, you can use Excel’s ABS (absolute value) function to subtract the two dates.

Number of Months
Calculating the number month between two dates in Excel is useful when you are figuring out loan, mortgage, or other annuity payments. However, subtracting dates to get months in Excel is a bit trickier and rarely returns the result you expected. This is because Excel can only calculate the number of months between two dates within the same year. Excel will ignore the year in a date and simply subtract the month portion of the date.
To calculate the number of months between two dates, you need to use a built in Excel function specifically designed for this purpose. The formula to do this looks like this:
=month(b2)-month(b1)
Notice that although there are clearly more than three months between the two dates in our example, Excel still returns a value of three.

So, this method of finding the number of months between two dates is only useful if the two dates are within the same year. Although this may seem limited, it is actually quite useful for calculating a variety of financial figures such as dynamically calculating an APY from a partial-year APR.
Like the example above, you can also use the ABS function here to disregard whether the first date is later than the second is and vice versa.
Number of Years
Although similar to the months example above, calculating the number of years is far more useful because you aren’t stuck with only calculating within the same year. Using a similar syntax for the formula, you can easily calculate the number of years between two dates. To calculate the number of years between the two dates above, use the following formula:
=year(b2)-year(b1)
For our example, Excel returns a value of two. Again, you can use the ABS function here to avoid determining which date is later than the other.

Notice that Excel made the calculation using only the year part of each date. It took into account neither the month nor day of either date. This is a problem, for example, if you wanted to calculate the difference between January 1, 2010 and December 31, 2010.
Although there are 364 days between these dates, Excel will still return a value of zero if you calculate the difference in years using the procedure above.
Although the results may not be what you expected, it is possible to subtract two cells in Excel and figure out the number of days, months, and years between two dates. Just be careful that you know about the quirks described above so you don’t unknowingly end up with incorrect data in your worksheet.