This Easter Egg Excel function hasn't been documented for around two decades now but its still there and it still works today in 2024 and in Microsoft 365. =DATEDIF() was originally there for the sake of compatibility with LOTUS-123.
Difficulty: We classify this tutorial as moderately easy. It is not for absolute beginners and you should ideally have some familiarity with using at least one or two simple built-in Excel functions.
In an absolute nutshell the syntax is:
=DATEDIF(D24,E24,"D")
where "D" is Day and can be substituted for "M" (Month) and "Y" (Year).
So, that's the quick answer and now let's have a slightly more detailed look at =DATEDIF(). At the end of this lesson there's also a video showing =DATEDIF() in action which takes you through the entire process.
The =DATEDIF() Function is very easy to use and it can quickly give you some meaningful and practical results which can really help you to visualise important aspects of any business over time. =DATEDIF() has innumerable real-world applications for business analytics and can provide insights that any organisation could benefit from no matter how big or small they are.
Because the =DATEDIF() Function is unsupported by Microsoft there are some 'buggy' aspects to it which we won't go into here in too much detail (although we do give one example when we look briefly at the function's additional operators).
The first thing you will probably notice is that because DateDif() is undocumented Excel won't help you to fill out the function as it does with all the other built-in Excel functions.
There are other scenarios too which may produce incorrect results, but we don't cover those scenarios here and now that you are aware of them its worth saying that the quick-win business benefits of using =DATEDIF() far outweigh any of the wrinkles that you might encounter.
So let's look at a practical example of =DATEDIF() in action:
At FourSquare Farms our chickens work five days on egg laying duties followed by a two-day break and we need to know which chickens to rotate off active duty this morning by working out how many days it is since each chicken last had a break. To do this we are going to use the =DATEDIF() Function.
We keep a record of the date each chicken has been working since in Column D. And in Column E we insert today's date using one of the following methods:
To insert today's date in Excel use the shortcut CTRL; (hold down the CTRL and semicolon keys simultaneously) in the cell that you want to display today's date. That's all there is to it. Just two keys needed.
If you want more control than you get with CTRL; then you can use the =TODAY() function. It takes a bit more typing than the shortcut CTRL; but it is also a lot more powerful as you can also use it to insert dates that are in the past as well as ones that are in the future. For instance =Today(+5) will insert the date that is five days into the future and =Today(-5) will insert the date that is five days in the past.
Now we want today's date in every cell in that column. If you just use the traditional click and drag with the black crosshair to do this your dates will increase incrementally and that's not what we want here. We want the AutoFill to insert the same date in each cell.
If you don't know the following simple trick then this can be very frustrating indeed, especially because dates work differently to numbers when using Excel AutoFill. But we have the solution.
To insert the same date in each cell in a column, first insert today's date in the top cell (CTRL;). Next, select the black crosshair from the bottom-right corner of the cell and drag downwards so that the dates are inserted incrementally.
Here comes the clever bit. Select all the cells that you want to change and use the shortcut keys CTRL and D by holding down the CTRL and D keys simultaneously. Watch all the dates immediately change to today's date before your eyes.
Now we have all of our data set up and we are ready to use the =DATEDIF() Function. As with all the best things in life, the beauty of =DATEDIF() is in its simplicity.
So, in the top cell of our table in Column F (F24) we're going to start our DateDif() Statement.
What we want to work out is the difference in days between Column D and Column E.
We type the following into Cell F24.
=DATEDIF(D24,E24,"D")
Then hit enter.
We now get an answer to the question of how many days Chantelle has been working for without a break which you can see here:
Notice that the "D" operator for the number of days is in quotations marks. It is important that you remember this or you will get an error.
If you want to work in months or years just replace the "D" operator with "M" or "Y".
Next, from the bottom right corner of cell F24 select the crosshair and drag it down the column to find out how long all of our other chickens have been working.
We can see that the =DATEDIF() function has provided us with some really useful information that we need to act upon here as four of our chickens have been working far too long without any days off, so we'd best address this quickly before Animal Welfare come chasing after us.
The complete process of deploying the Excel =DATEDIF() function can easily take less than a minute as you can see in the video below which walks you through the full process.
We're not going to go much further with DATEDIF in this tutorial, but we will show you one slightly more involved scenario in order to illustrate the function's capabilities.
Suppose that our dataset spans over different months and years but that we only want to show just the difference in days whilst ignoring or excluding the years and months. Here the DATEDIF function treats the calculation as if the months and years didn't exist.
The DateDif function has three handy, additional operators that you can use in such scenarios.
Here's an example which makes use of DATEDIF()'s MD operator:
When we calculate the number of days here (ignoring months and years) you will notice that one quirk of the DATEDIF() function here is that it treats every day as if it is in the next month. The count rolls over into another month even if the end date is the previous day in the same month (as in the first row of our results).
Once you start experimenting with the DATEDIF() function you will discover plenty of such wrinkles.
If you think about it though this is logical, because the function is ignoring the months themselves and therefore doesn't know that the end date is in the same month.
What is actually happening is that (in order to ignore the month of the end date), DATEDIF() has had to create a floating variable for the month in the start date and has used that to calculate the difference in days.
If you enjoyed this tutorial you might also like:
We come to you: Our regional, mobile Microsoft Excel trainers cover most locations of mainland UK for on-site visits including the English regions of the North West, North East, Yorkshire and the Humber, Greater London, the East of England, West Midlands, East Midlands, and also some parts of the South West of England (including Wiltshire, Bristol area and Gloucestershire) and South East of England (including Buckinghamshire, Oxfordshire, Berkshire, Hampshire and Surrey). Virtual classroom courses are available from anywhere via live video conferencing.
We really ❤ love helping organisations to master Microsoft Excel.
Our only question is: Will it be yours?
Call 0844 493 3699
Or email info@foursquaretraining.co.uk
Specialist educators with a wealth of experience and expertise, proven track records and excellent feedback.
Flexible instructor-led courses catering to YOUR specific learning needs and training requirements.
Over 18,000 students trained across almost every industry, sector and background.
Call 0844 493 3699
Or email info@foursquaretraining.co.uk
An excellent, clear and patient tutor who guided me through the course seamlessly.
M Menzies (Online Excel training 365 (virtual classroom))
Can I just pass on my thanks to your team for the training you provided in York. I've had lots of positive feedback from the staff involved.
J Whiley, NHS York and Selby (Excel training York)
Really useful. Really knowledgeable trainer.
A Ward, Aeromet (Advanced Excel Training Worcester)
The trainer explained everything really well. I found the course easy to follow.
V Broxham, Baywa-re Operational Services (Intermediate Excel training Milton Keynes)
Happy with everything.
M Aston, Bierce Surveying Ltd (Advanced Excel Training Aylesbury Buckinghamshire)
We have had a few people over the years but the way the trainer picked up our business and requirements so quickly – all I can is you have a diamond there.
S Jenkins, Concorde Glass (Intermediate Excel Training Grimsby)
We all thoroughly enjoyed the course, we learned a great deal and thought Sara was a brilliant trainer, very patient with a fantastic way of teaching us, so thank you for that.
C Waldock, Darlington Borough Council (Intermediate Excel training Darlington, County Durham)
☆ ☆ ☆ ☆ ☆ Five Star Review
We had some really great feedback from the last two training sessions,
on the quality of the content as well as the delivery from the trainer.
Excel Training London
The content covered the exact content required after the beginners course. The information will allow me to improve the spreadsheets currently in use.
L Powell, Dudley Building Society (Intermediate Excel Training Dudley)
Great course!
V Franklin, E-Leather (Excel Beginners Training Peterborough)
The training approach and style was great. Incredibly informative and supportive.
L Shier, One YMCA (Introduction to Excel Training Watford, Hertfordshire)
Great teacher!
J Smith, Fisher German (Intermediate Excel Training Canterbury, Kent)
Its an excellent course. I was impressed by the discovery of so many tools that will facilitate our working life. The trainer is excellent, everything was perfect.
S Green, HW Martin (Beginners Excel Training Cambridgeshire)
Very happy to learn so much.
O Chawishly, LM Information Delivery (Intermediate Excel Training Oxfordshire)
Covered all objectives. Wish We'd had two days.
B Hough, Homebase (VBA for Excel Training Milton Keynes)
The course was excellent, covering more in a single day of training than I anticipated would be possible with a high degree of clarity.
Unsigned, New Economy, (VBA for Excel Training Manchester)
Very informative, easy to follow. Trainer was clear with his explanations
S Nottingham, Denney O'Hara (Microsoft Excel training Leeds, West Yorkshire)
Excellent day!
L McLachlan, Grange School (Excel training Rochdale, Greater Manchester)
Brilliant Training, went at the right speed [and] was made relevant to work
Kathryn Strong, Tennants Distribution (Excel training Manchester)
Fantastic course, not too much information overload. Explained simple. Exactly what I needed. Many thanks.
K Stobbs, Depuy Spine - A Jonson and Jonson Company (Introductory Excel training Leeds, West Yorkshire)
The flexibility of the course was ideal.
S Walsh, Progress Rail (Advanced Excel training Edinburgh, Midlothian)
The guys who came to the course this week were very impressed with the whole set up and are now eager to attend the next level up.
E Dixon, Connaught PLC (Beginners Excel training Leeds, West Yorkshire)
The course has improved my knowledge of Microsoft Excel and was a good pace so easily understandable. Gerry was very patient and helped each of us where we needed it.
L Muir, Filtronic Broadband (Microsoft Excel training Newcastle Upon Tyne)
Although a total beginner on Excel, I found the course to be extremely helpful.
S Antonie, Filtronic (Excel training Shipley)
Made what I thought was going to be completely foreign to me easy to understand. I can actually see where I can use Excel in my day job now. Max was very good and took the time to make sure we understood. [...] Nothing could be improved.
C Elsmore, Elmwood Design (Excel training Leeds, West Yorkshire)
Very Useful.
J Collins, Cooper Research Technology Ltd (Advanced MS Excel Training Ripley, Derbyshire)
Enjoyable and informative.
N. Bell, Cosalt PLC (Excel advanced training Grimsby, Lincolnshire)
The training session went very well and I have had a lot of good feedback from the participants.
P Ogden, InterfaceFLOR (Microsoft Excel Training Halifax West Yorkshire)
Course exceeded expectations.
K. Richards, Ashfield Homes (Microsoft Excel Training Sutton-in-Ashfield, Nottinghamshire)
The day was very well constructed and presented.
D. Coulthand, Crossgates Shopping Centre, Leeds (Intermediate Microsoft Excel Training Leeds, West Yorkshire)
Training very clear. Never felt rushed or pressured to complete tasks. Each item explained and demonstrated very well. Easy to follow
S. Hope, Lear Corporation (Advanced Microsoft Excel Training Coventry, West Midlands)
Good course, good information, good trainer and at a nice tempo
A. Webster, BE Aerospace (Advanced Microsoft Excel Training Hinckley, Leicestershire)
Excellent, the best Excel course I have ever been on. Trainer gave time and patience to us all.
D. Gill, Persimmon Homes (Beginners Microsoft Excel Training Malmesbury, Wiltshire)
A very robust day's training.
T. Camp, Ideal Shopping (Beginners Microsoft Excel Training Peterborough, Cambridgeshire)
The course in Edinburgh was incredible
C. Rowley (Beginners Microsoft Excel Training Edinburgh, Midlothian)
☆ ☆ ☆ ☆ ☆ Five Star Review
Thank You. We got very good feedback from all who
attended the beginners course last week.
Virtual Classroom Excel Training Glasgow
To book a training course simply call 0844 493 3699, or email info@foursquaretraining.co.uk
UK Price Guide
Group day rates for private virtual courses & workplace courses
1-3 delegates: £450 plus VAT
4 delegates: £500 plus VAT
5 delegates: £550 plus VAT
6 delegates: £600 plus VAT
7 delegates: £650 plus VAT
8 delegates: £700 plus VAT
9 delegates: £750 plus VAT
10 delegates: £800 plus VAT
- trainer travel costs apply for on-site visits -
- prices based on one-day's training -
- Laptop hire charged separately -