Date conditional

EduPAz

Board Regular
Joined
Mar 18, 2017
Messages
69
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi,

Can someone please help me with this formula?

I have this info:
Column A = employee name
Column B = hiring day
Column C = Original vacation days per year (15 or 20)
**Column D = Xtra vacation days
Column E = Total vacation days (15+column D)

For every year worked after 4 years, the employee gets an extra day:

For 5 years, the employee gets 1 extra day. Total vacation days : 15+1
For 6 years, the employee gets 1 extra day. Total vacation days : 15+2
For 7 years, the employee gets 1 extra day. Total vacation days : 15+3
For 8 years, the employee gets 1 extra day. Total vacation days : 15+4
For 9 years, the employee gets 1 extra day. Total vacation days : 15+5

The maximum number of vacation days is 20. If the original vacation days per year (Column c) is 20, the extra day policy is not applied.

Thanks,

Edu
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
In column D put
Code:
[FONT=Verdana]=INT(YEARFRAC(B2,TODAY()))-4[/FONT]
This will calculate the "extra" number of days (though with new employees, this will start at -4 to give them the 5 years before they get an actual extra day!).
In column E, use the formula
Code:
[FONT=Verdana]=IF(C2+D2>=20,20,IF(D2<=0,C2,C2+D2))[/FONT]
This will add extra days if they have not already reached the maximum of 20 but leave the days unchanged if they have 0 or fewer extra days.
 
Upvote 0
Hi,

Thank you for your answer. How would be if my initial statement change in this way:


Column A = employee name
Column B = hiring day
Column C = Vacation days per year (15, 16, 17, 18,19 or 20) --> This is the number of vacation days that every employee has at January 1st 2019. For example, some employees have 17 days because at January 1st 2019, they have worked for 6 years.
**Column D = Xtra vacation days for the year (at today) --> The value would be 1 or 0. If the employee earns an extra day during the year (the employee complies the condition of year worked), put 1.
Column E = Total vacation days at today (column C + column D)

For every year worked after 4 years, the employee gets an extra day:

For 5 years, the employee gets 1 extra day. Total vacation days : 15+1
For 6 years, the employee gets 1 extra day. Total vacation days : 15+2
For 7 years, the employee gets 1 extra day. Total vacation days : 15+3
For 8 years, the employee gets 1 extra day. Total vacation days : 15+4
For 9 years, the employee gets 1 extra day. Total vacation days : 15+5

The maximum number of vacation days is 20. If the original vacation days per year (Column c) is 20, the extra day policy is not applied.

Thanks,

Edu
 
Upvote 0
Try this:

ABCDE
1NameHire dateDays at 1/1Extra this yearTotal days
2Fred23/08/201515015
3Joe21/12/201019019
4Bert03/05/201118119
5Mary30/08/200620020
6Sue14/03/201316117
7Jill12/06/200020020

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
C2=IF(YEARFRAC(B2,TODAY())<5,15,IF(YEARFRAC(B2,TODAY())>=9,20,15+INT(YEARFRAC(B2,DATE(YEAR(TODAY()),1,1)))-4))
D2=IF(TODAY()>=DATE(YEAR(TODAY()),MONTH(B2),DAY(B2)),1,0)
E2=C2+D2

<tbody>
</tbody>

<tbody>
</tbody>

In the final argument of C2, I start with 15 and subtract 4, as this reflects the way you work, but you could obviously change it to start with 11 and not subtract anything.
 
Last edited:
Upvote 0
Hi,

Thank you for your answer.
For column D, the formula is not capturing the condition:

For every year worked after 4 years, the employee gets an extra day:

For 5 years, the employee gets 1 extra day. Total vacation days : column c+column d
For 6 years, the employee gets 1 extra day. Total vacation days : column c+column d
For 7 years, the employee gets 1 extra day. Total vacation days : column c+column d
For 8 years, the employee gets 1 extra day. Total vacation days : column c+column d
For 9 years, the employee gets 1 extra day. Total vacation days : column c+column d

Total vacation days can not be greater than 20. If the employee already has 20 days in column c, the value in column d is zero

Edu
 
Upvote 0

Forum statistics

Threads
1,215,737
Messages
6,126,576
Members
449,318
Latest member
Son Raphon

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