# DATEDIF

Spread for WinForms provides advanced software components that support Excel import/export, full cell customization, an extensive calculation engine with over 450 functions and more, all with zero dependencies on Excel.

## Content



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

## Syntax

DATEDIF(*date1*,*date2*,*outputcode*)

## Arguments

The first two arguments are any dates, as strings, numeric values, or DateTime objects.
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 |

## Data Types

Accepts strings, numeric values, and DateTime objects. Strings and numbers are converted to DateTime objects.

## Examples

`DATEDIF(A1,B1,C1)`
`DATEDIF(R1C1,R1C2,R1C3)`
`DATEDIF("2001/1/1","2003/1/1","Y")`

## Version Available

This function is available in product version 2.0 or later.

## See Also

[DATEVALUE](/spreadnet/docs/latest/online-formula/formulas-functionsall/formulas-functsDtoG/FunctionDATEVALUE) \| [TIME](/spreadnet/docs/latest/online-formula/formulas-functionsall/formulas-functsTtoZ/FunctionTIME) \| [Date and Time Functions](/spreadnet/docs/latest/online-formula/formulas-overview/formulas-functs/formulas-functtypes/formulas-functsdatetime)