The syntax is as follows:
=DATEDIF (start_date, end_date, unit)
Where unit can be:
Unit | Result |
---|---|
"Y" | Difference in complete years |
"M" | Difference in complete months |
"D" | Difference in days |
"MD" | Difference in days, ignoring months and years |
"YM" | Difference in months, ignoring days and years |
"YD" | Difference in days, ignoring years |
Examples of situations where this might be useful:
- You are in HR and have a list of employee hire dates. You need to know how many months each employee has been employed (assume hire dates are in column A)
- =DATEDIF(A2,TODAY(),"M")
- You are reviewing contracts and need to know how many days it took from contract submission to contract approval (Assume submission dates are in column A and Approval dates in column B)
- =DATEDIF(A2,B2,"D")
I'll admit, I've used other Excel formulas to try and calculate this same result; this would have saved me time and headaches. Try it out!
(more info: https://exceljet.net/excel-functions/excel-datedif-function)