๐ Excel Basics #30 โ DATEDIF() & EDATE() Functions
When working with employee records, project timelines, subscriptions, loans, or customer data, you often need to calculate the time between dates or move a date forward or backward by a specific number of months.
Two useful functions are DATEDIF() and EDATE().
๐ 1. DATEDIF() Function
DATEDIF() calculates the difference between two dates.
Syntax:
=DATEDIF(start_date,end_date,unit)
The unit determines what you want to calculate.
Common units:
โข Y โ Complete years
โข M โ Complete months
โข D โ Total days
โข YM โ Remaining months after complete years
โข YD โ Remaining days after complete years
โข MD โ Remaining days after complete months
๐ Example 1 โ Calculate Complete Years
Suppose:
A2 = 01-Jan-2020
B2 = 19-Aug-2026
Formula:
=DATEDIF(A2,B2,"Y")
Result:
6
The employee has completed 6 full years.
๐ Example 2 โ Calculate Complete Months
=DATEDIF(A2,B2,"M")
This returns the total number of complete months between the two dates.
๐ Example 3 โ Calculate Total Days
=DATEDIF(A2,B2,"D")
This returns the total number of complete days between the dates.
๐ Example 4 โ Display Years and Months
You can combine multiple DATEDIF() functions:
=DATEDIF(A2,B2,"Y")&" Years "&DATEDIF(A2,B2,"YM")&" Months"
Example result:
6 Years 7 Months
This is useful for calculating employee tenure or customer relationship duration.
๐ 2. EDATE() Function
EDATE() returns a date that is a specified number of months before or after a starting date.
Syntax:
=EDATE(start_date,months)
๐ Example 1 โ Add Months
If:
A2 = 19-Aug-2026
Formula:
=EDATE(A2,3)
Result:
19-Nov-2026
๐ Example 2 โ Subtract Months
=EDATE(A2,-3)
This returns the date 3 months before the date in A2.
Result:
19-May-2026
๐ Real-World Example
Suppose a subscription starts on:
19-Aug-2026
and lasts for 12 months.
Formula:
=EDATE(A2,12)
Result:
19-Aug-2027
You can use this to calculate renewal dates.
๐ DATEDIF() vs EDATE()
DATEDIF() โ Calculates the difference between dates.
EDATE() โ Calculates a new date by adding/subtracting months.
Think:
๐ DATEDIF() โ How long?
๐ EDATE() โ What date after/before X months?
๐ Real-World Uses
โข Calculate employee experience.
โข Calculate customer tenure.
โข Calculate project duration.
โข Find subscription renewal dates.
โข Calculate loan or contract dates.
โข Track service anniversaries.
๐ Common Mistakes
โ Putting the end date before the start date in DATEDIF().
โ Using the wrong DATEDIF() unit.
โ Forgetting that DATEDIF() returns complete units, not rounded values.
โ Formatting an EDATE() result as a number instead of a date.
โ
Quick Tip
Remember:
DATEDIF() โ Difference between two dates
EDATE() โ Move a date by months
These functions are extremely useful when working with real-world business data.
Double Tap โค๏ธ For More
Post #2270
2.99K
- โค 13
- ๐ 2