DATEDIF Function
- DATEDIF
- Calculates the number of days, months, or years between two dates.
This function is provided for compatibility with Lotus 1-2-3.
Syntax: DATEDIF(start date, end date, unit)
If the start date is not an earlier date than the end date, DATEDIF will return an error. If you wish to use a cell reference to enter the unit, do not use quotation marks when entering the unit into the referenced cell.
Unit | Finds |
Y | The number of complete years in the period. |
M | The number of complete months in the period. |
D | The number of days in the period. |
MD | The difference between the days in start date and end date if the end date were within one month of the start date. |
YM | The difference between the months in start date and end date if the end date were within one year of the start date. |
YD | The difference between the days of start date and end date if the end date were within one year of the start date. |
For more information and to see the samples in a worksheet, download the sample workbook datedif.xls.
The DATEDIF function can be used to determine a persons age from their birth date using the following formula: =DATEDIF(Cell ref to Birth date, TODAY(), "y"). If the persons birth date is in cell C3, the formula would be =DATEDIF(C3, TODAY(), "y").