Calculate the difference between two dates
Let's say that you want find out how many days a customer takes to pay a bill or how long it takes to ship a product upon receipt of an approved order. There are several ways to calculate the difference between two dates.
What do you want to do?
Calculate the number of days between two dates
To do this task, use the subtraction () operator or the NETWORKDAYS function as shown in the following example.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How do I copy an example?

Select the example in this article.
Selecting an example from Help

Press CTRL+C.

In Excel, create a blank workbook or worksheet.

In the worksheet, select cell A1, and press CTRL+V.

To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.
After you copy the example to a blank worksheet, you can adapt it to suit your needs.


For more information about how to use this function, see NETWORKDAYS function.
Calculate the number of months between two dates
To do this task, use the MONTH and YEAR functions as shown in the following example.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How do I copy an example?

Select the example in this article.
Selecting an example from Help

Press CTRL+C.

In Excel, create a blank workbook or worksheet.

In the worksheet, select cell A1, and press CTRL+V.

To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.
After you copy the example to a blank worksheet, you can adapt it to suit your needs.


For more information about how to use these functions, see MONTH function and YEAR function.
Calculate the number of years between two dates
To do this task, use the YEAR function as shown in the following example.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How do I copy an example?

Select the example in this article.
Selecting an example from Help

Press CTRL+C.

In Excel, create a blank workbook or worksheet.

In the worksheet, select cell A1, and press CTRL+V.

To switch between viewing the results and viewing the formulas that return the results, press CTRL+` (grave accent), or on the Formulas tab, in the Formula Auditing group, click the Show Formulas button.
After you copy the example to a blank worksheet, you can adapt it to suit your needs.



You can format the dates as numbers. Select the cell and, on the Home tab, in the Number group, click the arrow, and then click Number.

If you subtract a later date from an earlier date, the error #### appears in the cell.
For more information about how to use this function, see YEAR function.