barry houdini
MrExcel MVP
- Joined
- Mar 23, 2005
- Messages
- 20,825
Pgc asked me to set the latest “tough problem”. I tried to come up with something that wouldn’t be too tough, but might stretch some of you a little.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o> </o>
If you want to post comments or ideas, rather than fully-formed solutions, please feel free, all contributions are welcome.<o></o>
<o> </o>
The problem<o></o>
<o> </o>
A1 contains an employee "hire date". Employees accrue hours on their anniversary date each month based on the following<o></o>
<o> </o>
0 years – 0 hrs per month<o></o>
2 years – 3 hrs per month<o></o>
5 years – 7 hrs per month<o></o>
8 years – 10 hrs per month<o></o>
15 years+ – 20 hrs per month<o></o>
<o> </o>
You need to supply a single formula which will calculate the hours accrued so far this calendar year, you can assume that today’s date is in T1.<o></o>
<o> </o>
If the hire date is a date like 31<SUP>st </SUP>May then, for months with less than 31 days, the hours will accrue on the last day of that month. Employees earn their first hours on their 2<SUP>nd</SUP> anniversary.<o></o>
<o> </o>
Example<o></o>
<o> </o>
Hire date <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-comffice:smarttags" /><st1:date Month="6" Day="30" Year="2004">30th June 2004</st1:date> <o></o>
<o> </o>
This employee's first hours will accrue on <st1:date Month="6" Day="30" Year="2006">30<SUP>th</SUP> June 2006</st1:date>. <o></o>
<o> </o>
During 2009 the employee will have accrued 0 hours by today (20<SUP>th</SUP> January) but will then earn 3 hours per month on the 30<SUP>th</SUP> of each month (or 28<SUP>th</SUP> February because that month has no 30th), until 30th June, which is the 5 year anniversary, so hours earned on that day, and every subsequent 30th in 2009, will be 7.<o></o>
<o> </o>
So if today was <st1:date Month="4" Day="1" Year="2009">1<SUP>st</SUP> April 2009</st1:date> then the formula should give the answer 9 (3+3+3), but if today was 3<st1:date Month="12" Day="1" Year="2009">1<SUP>st</SUP> December 2009</st1:date> the formula will give 64 (3+3+3+3+3+7+7+7+7+7+7+7). Of course the result will revert to zero on <st1:date Month="1" Day="1" Year="2010">1<SUP>st</SUP> January 2010</st1:date><o></o>
<o> </o>
As with previous problems, if you are an MVP, or if you found this simple, then please wait 24 hours before you post to give others a chance.<o></o>
<o> </o>
Thank you for reading<o></o>
<o> </o>
Regards, barry<o></o>
<o> </o>
If you want to post comments or ideas, rather than fully-formed solutions, please feel free, all contributions are welcome.<o></o>
<o> </o>
The problem<o></o>
<o> </o>
A1 contains an employee "hire date". Employees accrue hours on their anniversary date each month based on the following<o></o>
<o> </o>
0 years – 0 hrs per month<o></o>
2 years – 3 hrs per month<o></o>
5 years – 7 hrs per month<o></o>
8 years – 10 hrs per month<o></o>
15 years+ – 20 hrs per month<o></o>
<o> </o>
You need to supply a single formula which will calculate the hours accrued so far this calendar year, you can assume that today’s date is in T1.<o></o>
<o> </o>
If the hire date is a date like 31<SUP>st </SUP>May then, for months with less than 31 days, the hours will accrue on the last day of that month. Employees earn their first hours on their 2<SUP>nd</SUP> anniversary.<o></o>
<o> </o>
Example<o></o>
<o> </o>
Hire date <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-comffice:smarttags" /><st1:date Month="6" Day="30" Year="2004">30th June 2004</st1:date> <o></o>
<o> </o>
This employee's first hours will accrue on <st1:date Month="6" Day="30" Year="2006">30<SUP>th</SUP> June 2006</st1:date>. <o></o>
<o> </o>
During 2009 the employee will have accrued 0 hours by today (20<SUP>th</SUP> January) but will then earn 3 hours per month on the 30<SUP>th</SUP> of each month (or 28<SUP>th</SUP> February because that month has no 30th), until 30th June, which is the 5 year anniversary, so hours earned on that day, and every subsequent 30th in 2009, will be 7.<o></o>
<o> </o>
So if today was <st1:date Month="4" Day="1" Year="2009">1<SUP>st</SUP> April 2009</st1:date> then the formula should give the answer 9 (3+3+3), but if today was 3<st1:date Month="12" Day="1" Year="2009">1<SUP>st</SUP> December 2009</st1:date> the formula will give 64 (3+3+3+3+3+7+7+7+7+7+7+7). Of course the result will revert to zero on <st1:date Month="1" Day="1" Year="2010">1<SUP>st</SUP> January 2010</st1:date><o></o>
<o> </o>
As with previous problems, if you are an MVP, or if you found this simple, then please wait 24 hours before you post to give others a chance.<o></o>
<o> </o>
Thank you for reading<o></o>
<o> </o>
Regards, barry<o></o>