4 ways to calculate the duration between two dates - Data Cycle Analytics (2024)

In any working environment, there are various instances where you would be required to calculate the duration between two dates.

A human resource officer would need to know how long a given employee has worked with the company or the actual age of the various employees for planning purposes. In an automotive industry, you would need to compute how long, say a given vehicle has taken to be serviced. For most NGOs, it would be needful to know, based on the contractual terms of various consultants, how many months/years are remaining and subsequently, how many employees have their contracts ending, say in the next 3 months, 6 months, and so on.

There are many ways that you can achieve to calculate the difference between any two dates in Excel.

For this example, we shall discuss how to calculate the length of service of various employees as at a given date, but the concept applies in all the scenarios described above.

Calculate the duration of service of employees

We have the following subset of data extract.

4 ways to calculate the duration between two dates - Data Cycle Analytics (1)

In cell C2 we shall type a date as at which we shall compute the length of service. This can be (1) a date that you hardcode, or (2) a date representing today’s date, or (3) a formula that returns the end of the previous month with reference to today’s date.

To always use the current (i.e. today’s) date, type the following in cell C2:

=TODAY( )

The Excel’s TODAY function will always return the current date.

To always use the end of the previous month with reference to today’s date, we shall type the following in C2:

=EOMONTH (TODAY( ), -1)

The EOMONTH function normally returns a serial number that represents the end of the month, “x” number of months before or after the specified date. The number of months before or after can be a positive number or a negative number or zero if you want to return the end of the current month. For instance, if the TODAY function wrapped inside this formula is assumed to be “8/8/2017” then using 0 as the last parameter will result in “31/8/2017”, using -2 will return “30/6/2017” whereas using a +4 will yield “31/12/2017”

In this example, we shall enter this EOMONTH function in cell C2 to always consider the end of the previous month.

Different approaches to compute differences between two dates

Let us explore various methods to calculate the duration between two dates.

Method 1: Subtract the two dates

The obvious method I have seen with various trainees is to subtract the date of joining from the specified end date and then divide the resultant value by 365 (or 360 for other regions) as shown below.

4 ways to calculate the duration between two dates - Data Cycle Analytics (2)

The equivalent of the formula shown in cell E5 above would be = DAYS ($C$2, D6)/365 which would give similar results.

Method 2: Subtract the years

In this approach, we assume we just need to compute the difference between the two dates as whole years, as is the case when you want to compute your age as at the last birthday.

We therefore employ the formula shown in the figure below.

4 ways to calculate the duration between two dates - Data Cycle Analytics (3)

This approach rounds the result to the nearest whole number.

Method 3: Using the YEARFRAC function

This method gives similar results with the first method above. That is, it will compute the fractional year differences between two dates.

For instance, if the last day is “31/07/2017” and you joined the company on “27/09/1998” then the formula will compute the difference taking into account differential months. So, whereas method 2 would give 19 as the difference in years, YEARFRAC will yield 18.84.

Take a look.

4 ways to calculate the duration between two dates - Data Cycle Analytics (4)

Notice that in this case you start by specifying the date of joining in the formula.

Let us compare the results

The figure that follows compares the output of the various approaches discussed so far.

4 ways to calculate the duration between two dates - Data Cycle Analytics (5)

Method 4: Using DATEDIF function

When you type DATEDIF as you would do with any other formulas, this formula doesn’t show a prompt (normally called the intellisense) as other formulas do. It was popular in earlier Excel versions 2003 and earlier) but has since not been given a lot of focus. I guess Microsoft might stop supporting it very soon (my guess).

This function computes the difference in either the completed/full years, months or days, between two dates. Just like the YEARFRAC function, it also requires you to specify the starting and the ending date. However, you would need to specify the time unit of output, in terms of years, months or days.

Syntax: DATEDIF (Start_date, End_date, Unit)

There are six different outputs that you can get based on the time unit you specify as follows:[/vc_column_text][gem_table]

Unit
Output
“y”Difference in terms of complete years
“m”Difference in terms of complete months
“d”Difference in terms of complete days
“yd”Returns the difference of complete days, ignoring the ones in the years that have been completed. Simply put, for the specified start date, it takes the equivalent date in the immediate previous year as the basis of subtracting the completed days
“ym”Returns the difference of complete months, ignoring the ones in the years that have been completed. It takes the immediate previous year as the basis of subtracting the full months
“md”This interval just subtracts the day part of the two dates. For instance, in the table below, notice the “md” column is the difference between the day element of the two dates. In row 9 for example it is 31-1=30

The figure below illustrates all the six possible outputs.

4 ways to calculate the duration between two dates - Data Cycle Analytics (6)

In conclusion

The various approaches discussed above are enough arsenals for various scenarios you may encounter. Should you have comments or questions regarding manipulating dates in Excel, please lodge them in the comments area below.

Please share the article with your colleagues and let them improve how they work with Excel.

4 ways to calculate the duration between two dates - Data Cycle Analytics (2024)
Top Articles
30 Incredibly Easy Ways To Be Happier, Wealthier, and More Successful
Things To Stop Buying To Save Money
Omega Pizza-Roast Beef -Seafood Middleton Menu
Craigslist Myrtle Beach Motorcycles For Sale By Owner
Bubble Guppies Who's Gonna Play The Big Bad Wolf Dailymotion
Skamania Lodge Groupon
Www.politicser.com Pepperboy News
Cad Calls Meriden Ct
Flixtor The Meg
Women's Beauty Parlour Near Me
Dr Lisa Jones Dvm Married
Plus Portals Stscg
Chase Claypool Pfr
12 Best Craigslist Apps for Android and iOS (2024)
Explore Top Free Tattoo Fonts: Style Your Ink Perfectly! 🖌️
Sams Early Hours
Hca Florida Middleburg Emergency Reviews
Labor Gigs On Craigslist
State HOF Adds 25 More Players
Committees Of Correspondence | Encyclopedia.com
Locate At&T Store Near Me
Spergo Net Worth 2022
The Grand Canyon main water line has broken dozens of times. Why is it getting a major fix only now?
Zalog Forum
Contracts for May 28, 2020
Yog-Sothoth
South Bend Weather Underground
Baldur's Gate 3: Should You Obey Vlaakith?
55Th And Kedzie Elite Staffing
Xxn Abbreviation List 2017 Pdf
Coindraw App
Miller Plonka Obituaries
Mark Ronchetti Daughters
Dentist That Accept Horizon Nj Health
Loopnet Properties For Sale
Fastpitch Softball Pitching Tips for Beginners Part 1 | STACK
Cbs Trade Value Chart Week 10
Solve 100000div3= | Microsoft Math Solver
What Time Is First Light Tomorrow Morning
Cranston Sewer Tax
Improving curriculum alignment and achieving learning goals by making the curriculum visible | Semantic Scholar
Arnesons Webcam
Csgold Uva
Spreading Unverified Info Crossword Clue
Sky Dental Cartersville
Doelpuntenteller Robert Mühren eindigt op 38: "Afsluiten in stijl toch?"
Zits Comic Arcamax
Provincial Freeman (Toronto and Chatham, ON: Mary Ann Shadd Cary (October 9, 1823 – June 5, 1893)), November 3, 1855, p. 1
Tamilyogi Cc
Bloons Tower Defense 1 Unblocked
Pauline Frommer's Paris 2007 (Pauline Frommer Guides) - SILO.PUB
Latest Posts
Article information

Author: Kieth Sipes

Last Updated:

Views: 5670

Rating: 4.7 / 5 (67 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Kieth Sipes

Birthday: 2001-04-14

Address: Suite 492 62479 Champlin Loop, South Catrice, MS 57271

Phone: +9663362133320

Job: District Sales Analyst

Hobby: Digital arts, Dance, Ghost hunting, Worldbuilding, Kayaking, Table tennis, 3D printing

Introduction: My name is Kieth Sipes, I am a zany, rich, courageous, powerful, faithful, jolly, excited person who loves writing and wants to share my knowledge and understanding with you.