Today's date - 5 years

Fester675

Board Regular
Joined
Sep 16, 2016
Messages
116
Hi all - I NEED SOME HELP!!

I have 3 drop down lists - DATE (D2); MONTH (E2); YEAR (G2)

I have annual leave allowance based on time served - (Q2) 25.0 (<5 years service); (Q3) 30.0 (>5 years service but started after 30/4/2013); (Q4) 31.5 (>5 years service and started on or prior to 30/4/2013)

My problem is when 2019 is selected in (G2) it results in 30.0 (Q3) - this is the only year with a problem!!

Here's the formula used...

=IF(G2="YEAR","",IF(AND(YEAR(TODAY())-G2<5,YEAR(TODAY())>G2),Q2,IF(DATE(G2,E2,D2)<=DATE(2013,4,30),Q4,IF(DATE(G2,E2,D2)>DATE(2013,4,30),Q3))))
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
11,689
Office Version
2013
Platform
Windows
If it would not cause your results to be a day off, try using 'less than/equal to ' and 'greater than/equal to'
Code:
<=
>=
that would keep the results from being zero for some of the formula parts, which seems to be part of the problem. You are only using the equal to in one place at present. It seemed to work right when I changed it on a test setup.
 
Last edited:

Fester675

Board Regular
Joined
Sep 16, 2016
Messages
116
Thanks JLG - but it's still not changing!
I'm guessing that I'm going to have to use all 3 dropdown boxes to determine the precise date? So - is the YEAR <5 years, the month & year <5 years, the dd/mm/yyyy <5 years from the current day; and the same for >=

=IF(G2="YEAR","",IF(AND(YEAR(TODAY())-G2<=5,YEAR(TODAY())>=G2),Q2,IF(DATE(G2,E2,D2)<=DATE(2013,4,30),Q4,IF(DATE(G2,E2,D2)>=DATE(2013,4,30),Q3))))
 

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,218
Try this...

=IF(G2="YEAR","",IF(DATE(G2,E2,D2)<=DATE(2013,4,30),Q4,IF(DATE(G2+5,E2,D2)<=TODAY(),Q3,Q2)))
 

Watch MrExcel Video

Forum statistics

Threads
1,090,472
Messages
5,414,728
Members
403,544
Latest member
Phx007

This Week's Hot Topics

Top