# DATEDIF

## Content

This function returns the number of days, months, or years between two dates.

## Syntax

`DATEDIF(date1, date2, outputcode)`

## Arguments

<span data-teams="true">This function has these arguments:</span>

| <span data-teams="true">Argument</span> | <span data-teams="true">Description</span> |
| -------- | ----------- |
| <span data-teams="true"> </span>*<span data-teams="true">date1</span>* | <span data-teams="true">[Required] The starting date, as a string, numeric value, or DateTime object.</span> |
| <span data-teams="true"> </span>*<span data-teams="true">date2</span>* | <span data-teams="true">[Required] The ending date, as a string, numeric value, or DateTime object.</span> |
| *outputcode* | [Required] A string code that specifies the unit of difference ("D","M","Y","YD","YM","MD"). |

The output codes are:

| Code | Description |
| ---- | ----------- |
| *"D"* | The number of days between date1 and date2 |
| *"M"* | The number of complete months between date1 and date2 |
| *"Y"* | The number of complete years between date1 and date2 |
| "YD" | The number of days between date1 and date2 as if they were in the same year |
| "YM" | The number of months between date1 and date2 as if they were in the same year |
| "MD" | The number of days between date1 and date2 as if they were in the same month and year |

## Examples

`DATEDIF(A1,B1,C1)`
`DATEDIF(R1C1,R1C2,R1C3)`