Solved

Excel - Calculation On Dates

Posted on 2014-01-30
8
256 Views
Last Modified: 2014-01-30
Hello,

I'm trying to come up with a formula that will look at a hire date and end of year date.  If the total months exceeds 9 months, then the statement is true.  Less than 9 months the statement is false.  For example, an employee is hired 08/15/2013 and the end of year date is 12/31/2013.  Since the total time of employment is less than 9 months the statement would be false.

Any recommendations?
0
Comment
Question by:Escanaba
8 Comments
 
LVL 19

Expert Comment

by:Ken Butters
ID: 39820934
there are probably a lot of ways to do this..

1)  use the analysis toolpak described here: http://office.microsoft.com/en-us/excel-help/edate-HP005209073.aspx   This would allow you to subtract 9 months from the end of year date, and compare it to your hire date to see which is greater.

2) compare your hire date to March 31 of the current year.  If the hire date is less than march 31 of the current year... then you would have value of true.
0
 
LVL 22

Accepted Solution

by:
spattewar earned 500 total points
ID: 39820961
Hi,

How about using the datedif() formula in excel?

=IF(datedif(earlierdate,laterdate,"m")>8,TRUE,FALSE")

What would you want if the employment is exactly 9 months?

hope it helps.
0
 
LVL 49

Expert Comment

by:Rgonzo1971
ID: 39820967
Hi,

Attention if the person is hired April 1st is True or False then you have to compare accordingly

Regards
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 19

Expert Comment

by:Ken Butters
ID: 39821025
@spattewar   Note : the only reason I would probably try to avoid Datedif is because it doesn't handle the calculation properly when the later month has fewer days in it that the earlier month.

For example... April has 30 days, and January has 31 days.

If you do a datedif on those to dates the result will be 2.  However January 31 to April 30 is 3 months not 2.  

In this case when we are using end of year, you would be ok because the later date happens to be December 31, and you never have more than 31 days in a month... but at any rate it is something to be aware of when you do date calculations.  

That is what the EDATE from the analysis tookpak corrects.

If exactly 9 months is an issue one way or another, then you can always adjust by one day as necessary.
0
 
LVL 22

Expert Comment

by:spattewar
ID: 39821086
Yes Ken. That is correct but it would work in this scenario. Thanks for putting the information.
0
 
LVL 9

Expert Comment

by:Christopher Jay Wolff
ID: 39821232
Hi all.


Would it be good to use the YEARFRAC function?  In Office 2013 it looks like this from the help file, and I added my own data in column G to test it.  There are remarks in the help file stating the function YEARFRAC may not work properly with dates entered as text, yet it appears that is what they did in the example.  I at least formatted my date cells in column G to be date format and it seems to work.

Here is how it looks showing 9 month IF statement...
Excel screen grab of YEARFRAC1

and here it is showing YEARFRAC function...
Excel screen grab of YEARFRAC2
0
 
LVL 3

Expert Comment

by:ola_erik
ID: 39821430
The number of days of nine months are

2009-01-25      2009-10-25      273
2009-02-25      2009-11-25      273
2009-03-25      2009-12-25      275
2009-04-25      2010-01-25      275
2009-05-25      2010-02-25      276
2009-06-25      2010-03-25      273
2009-07-25      2010-04-25      274
2009-08-25      2010-05-25      273
2009-09-25      2010-06-25      273
2009-10-25      2010-07-25      273
2009-11-25      2010-08-25      273
2009-12-25      2010-09-25      274
(2009 was a non-leap year.)

the third column is the simple subtraction between the first two giving the number of days.

=(A2-A1)

It means anyone employed for 272 or less days does not have 9 months
Anyone employed 276 or more days are always employed for at least 9 months.

What to do with the ones with 273-275 days? If it's a legal framework talking about nine months it often have this defined, ask them.

Sometimes calculations are done with 30 day months only, which would mean 270 days.

So, use 270 or 272 days as a limit and clear it with whoever is responsible for policy.

so:
emp date    EOY date    =(B1-A1)>269
0
 
LVL 1

Author Closing Comment

by:Escanaba
ID: 39821450
This will work.  Thank you.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question