DATEDIF Function in Excel
In this blog post we will learn about “DATEDIF” function in excel. In excel DATEDIF function is used to calculate the difference between two dates in the form of days, moths and years.
Syntax of “DATEDIF Function”:
The syntax of DATEDIF function in excel is as below:
=DATEDIF(Start Date, End Date, Unit)
Arguments of “DATEDIF Function”:
There are total 03 arguments required to get desired result with this function.
Start Date: This is the 1st date or the starting date from the period from which we want to calculate the difference between dates.
End Date: This is the 2nd date or the ending date from the period from which we want to calculate the difference between dates.
Unit: The output of DATEDIF function will depend on this argument. There are total 06 units available for this arguments as listed below. We have to enter this argument in between two double inverted commas ex: “Unit”.
“Y”: With this unit, DATEDIF function will return number of complete years between Start Date and End Date.
“M”: With this unit, DATEDIF function will return number of complete months between Start Date and End Date.
“D”: With this unit, DATEDIF function will return number of complete months between Start Date and End Date.
“MD”: With this unit, DATEDIF function will return number of days between Start Date and End Date (by ignoring Months).
“YM”: With this unit, DATEDIF function will return number of months between Start Date and End Date (by ignoring Years).
“YD”: With this unit, DATEDIF function will return number of days between Start Date and End Date (by ignoring Years).
Example of “DATEDIF Function”:
Let’s take below example to apply DATEDIF Function in excel. We have entered Start Date in column A, End Date in Column B and the output is calculated for each of the units mentioned above. For your understanding, respective units are listed in column C. These units we can also see the in the column E where we have listed the exact formula which we have used.
NOTE: if Start Date is greater than End Date then excel will give us #NUM error.
Just for your reference, I have entered the Start Date which is greater than End Date and we can see that excel is giving us #NUM error in Output column.
Hence, to get the desired result using DATEDIF function, we have to take care that Start Date should not be greater than End Date.
I hope you can now use this DATEDIF function in excel effectively.
Comments
Post a Comment