The poor, ignored, hardly supported DATEDIF function

jdellasala

Well-known Member
Joined
Dec 11, 2020
Messages
751
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
I don't remember how, but a couple of years back I discovered the DATEDIF function.
You won't find it Excel's Functions lists, when you type "=DATEDIF" TAB will not add a opening parenthesis, and provides no parameter information. Yet, when you type "=DATEDIF(" with the opening parenthesis, it will appear in the Tool Tip, and you can click on the Tool Tip name to get the function's help!
1671363794423.png

It's even on the Microsoft Support site!
I THINK it is a holdover from Lotus 123 compatibility, but don't know for sure. However, I really like this function, and it provides information that is otherwise more cumbersome to get:
Book1
ABC
101/01/202112/18/2022DATEDIF( start_date, end_date, unit )
2ParameterValueMeaning
3Y1The number of complete years in the period.
4M23The number of complete months in the period.
5D716The number of days in the period.
6MD17The difference between the days in start_date and end_date. The months and years of the dates are ignored. Important: We don't recommend using the "MD" argument, as there are known limitations with it. See the known issues section below.
7YM11The difference between the months in start_date and end_date. The days and years of the dates are ignored
8YD351The difference between the days of start_date and end_date. The years of the dates are ignored.
Sheet1
Cell Formulas
RangeFormula
B1B1=TODAY()
B3:B8B3=DATEDIF($A$1,$B$1,A3)

With it, you can easily do fun stuff like this:
Cell Formulas
RangeFormula
E12E12="You are "&TEXT(DATEDIF(D12,D13,"D"),"#,###")&" days old!"
D13D13=TODAY()
E13E13="That is "&DATEDIF(D12,D13,"Y")&" Years, "&DATEDIF(D12,D13,"YM")&" Months, "&DATEDIF(D12,D13,"MD")&" Days Old!"
And no, that is not my birthday.

Anyone else familiar with this function? Know about its history or why it's not officially supported?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
On another post, there is this reaction. Post in thread 'Datedif Function not accurate' Datedif Function not accurate
The subject isn't true. The difference between two dates 365 days APART is always one less than the number of days because it's calculating the difference between the two numbers, not counting the number of items between the two dates including both dates. Effectively, the subtraction starts counting at 10/2/2020.
That's pretty commonly known, and needs to be compensated for as needed whether needed for simple subtraction of the start date from the end date, or using DATEDIF, or even the DAYS function! The only place I see it kind of work is in the formula
Excel Formula:
=SEQUENCE(365,,DATEVALUE("10/1/2020"))
which returns a column of dates from 10/1/2020 to 9/30/2021.
The "Known issues" relates only to using the "MD" option, and only under specific circumstances.
 
Upvote 0
The link was supposed to bring you directly to the reaction of Peter_SSs , with a link to some Microsoft information.
 
Upvote 0
The link was supposed to bring you directly to the reaction of Peter_SSs , with a link to some Microsoft information.
The link in the article is the same one I have above, and only reports the potential inaccuracy of the MD parameter. It is nearly identical to the information in the Excel help.
 
Upvote 0
Simply overlooked there was a link in your first post. Since Peters' link clearly states it is about Lotus 123, I never expected you reference to the same.
In a professional context, I never needed such a function. However for aging of customer tickets, open orders, project Running, etc it might be handy as it reads better then say 4563 days open. Now that's a long time 😲
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,958
Members
449,096
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top