# 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" style="margin: 0px; padding: 0px; -webkit-font-smoothing: antialiased; box-sizing: border-box;">This function has these arguments:</span>

| <span data-teams="true" style="margin: 0px; padding: 0px; -webkit-font-smoothing: antialiased; box-sizing: border-box;">Argument</span> | <span data-teams="true" style="margin: 0px; padding: 0px; -webkit-font-smoothing: antialiased; box-sizing: border-box;">Description</span> |
| -------- | ----------- |
| <span data-teams="true" style="margin: 0px; padding: 0px; -webkit-font-smoothing: antialiased; box-sizing: border-box;"> </span>*<span data-teams="true" style="margin: 0px; padding: 0px; -webkit-font-smoothing: antialiased; box-sizing: border-box;">date1</span>* | <span data-teams="true" style="margin: 0px; padding: 0px; -webkit-font-smoothing: antialiased; box-sizing: border-box;">[Required] The starting date, as a string, numeric value, or DateTime object</span> |
| <span data-teams="true" style="margin: 0px; padding: 0px; -webkit-font-smoothing: antialiased; box-sizing: border-box;"> </span>*<span data-teams="true" style="margin: 0px; padding: 0px; -webkit-font-smoothing: antialiased; box-sizing: border-box;">date2</span>* | <span data-teams="true" style="margin: 0px; padding: 0px; -webkit-font-smoothing: antialiased; box-sizing: border-box;">[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)`