Calculate the difference between two dates
Let's say 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
Calculate the number of months between two dates
Calculate the number of years between two dates
Calculate the number of days between two dates
To do this task, use the subtraction (-) operator or the NETWORKDAYS function.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
- Create a blank workbook or worksheet.
- Select the example in the Help topic.
Note Do not select the row or column headers.
Selecting an example from Help
- Press CTRL+C.
- 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
Formulastab, in theFormula Auditinggroup, click theShow Formulasbutton.
|
|
Note 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.
Function details
Calculate the number of months between two dates
To do this task, use the MONTH and YEAR functions.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
- Create a blank workbook or worksheet.
- Select the example in the Help topic.
Note Do not select the row or column headers.
Selecting an example from Help
- Press CTRL+C.
- 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
Formulastab, in theFormula Auditinggroup, click theShow Formulasbutton.
|
|
Note 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.
Function details
Calculate the number of years between two dates
To do this task, use the YEAR function.
Example
The example may be easier to understand if you copy it to a blank worksheet.
How to copy an example
- Create a blank workbook or worksheet.
- Select the example in the Help topic.
Note Do not select the row or column headers.
Selecting an example from Help
- Press CTRL+C.
- 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
Formulastab, in theFormula Auditinggroup, click theShow Formulasbutton.
|
|
Notes:
-
Note You can format the dates as numbers. Select the cell, and on the
Hometab, in theNumbergroup, click the arrow, and then clickNumber. - You cannot subtract a date that is later than another date, or the error #### appears in the cell.
Function details
![]()