Years Months Days - 1113 - Learn Excel from MrExcel Podcast

If you like this content, please consider visiting the video on YouTube and subscribe to the MrExcel Channel to show your support!
This video has been published on Oct 1, 2009.
Med asks how to calculate Years, Months, Days between two dates. Episode 1113 discusses the elusive DATEDIF function.

This blog is the video podcast companion to the book, Learn Excel 97-2007 from MrExcel. Download a new two minute video every workday to learn one of the 377 tips from the book!
maxresdefault.jpg


Transcript of the video:
Hey, welcome back to the MrExcel netcast, I'm Bill Jelen.
Basically, you start out with massive amounts of data, and say “How we're going to analyze this?” Well, let's fire up a Pivot table and see if we can solve this problem!
Hey, welcome back to the MrExcel netcast, I'm Bill Jelen.
Today's question sent in by Med.
Med’s from Denmark, Med has a begin date and an end date, he has to figure out that number of years, months and days between them.
Doesn't want to use some average like 30 days per month, and there is an exact function that will do this.
I promise Microsoft won't tell you about it, it's the one function that's been in Excel, and they've only document at once, I think, back in Excel 2000, was never documented since then.
It's been around forever, and probably because it was, you know, Lotus or something, sort of compatibility.
So here's how it works, the function is called DATEDIF, the DATEDIF function.
You specify the earlier date, I'll press F4 F4 F4 to lock that down to the column, and then the later date, F4 F4 F4 to lock that down, alright.
Now here's the thing, we have to put in a code now, this third parameter is a code, and the code to get years, appropriately enough, is a Y, alright.
So that works out, I'm going to put that up here in C1, I'll press F4 twice to lock that down to just the row, and so that is 29 years, cool, right?
Copy that over, and we get to see how many years everything is.
But now the problem is, when we copy this over to get months, look at this, 351 months.
Well, what is that?
That's 29 years *12+ the months that are left over, so it's very unintuitive.
The code up here, instead of M for months, is YM.
So that says “Hey, we're already using Y somewhere else, just give me the months in excess of the last year.” And so there, that's 29 years 3 months, alright.
Now we're going to copy this over one more time for the days, alright and again, look at that, that's the total number of days, so not D. Now following the same pattern, I can kind of see whoever created this, what they're thinking, put MD!
The M says “We're using M somewhere else, so give me the days in excess of that month.” And so there we have 29 years 3 months 4 days, there you have it, the DATEDIF function, give that a try!
Want to thank you for stopping by, we'll see you next time for another netcast from MrExcel!
Well thanks for stopping by, we'll see you next time for another netcast from MrExcel!
 

Forum statistics

Threads
1,223,702
Messages
6,173,932
Members
452,539
Latest member
delvey

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