Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula Doesn't Account For February 2

Status
Not open for further replies.

shelby55

Technical User
Jun 27, 2003
1,229
CA
Hi

I am using Excel 2003.

Skip helped with a formula for finding the month that is 5 months less than the user selected "dateSelected" but it doesn't account for February. In other words, when July 31 is selected, March 3 shows instead of Feb but March is already selected for the 31 (and only one March of data exists).

The code is:
Code:
=IF(DATE(YEAR(DateSelected), MONTH(DateSelected)-5, DAY(DateSelected))<MIN(MyDates),MIN(MyDates),DATE(YEAR(DateSelected), MONTH(DateSelected)-5, DAY(DateSelected)))

Any assistance greatly appreciated, thanks.
 


Use this
[tt]
=IF(DATE(YEAR(DateSelected), MONTH(DateSelected)-4, 0)<MIN(MyDates),MIN(MyDates),DATE(YEAR(DateSelected), MONTH(DateSelected)-4, 0))
[/tt]


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
HI

Awesome, thanks very much...works great!
 


Sorry that I overlooked that detail originally.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Can you say what you want the results to be for 31 July, 30 July, 29 July, and 28 July, less 5 months? Would they all return 28 Feb? ( assuming a non-leap year )

Cheers, Glenn.

Beauty is in the eye of the beerholder.
 
D'oh. all done and dusted by the time I replied .... again!

Cheers, Glenn.

Beauty is in the eye of the beerholder.
 
Hi

But the fact that you responded was still appreciated, Glenn! Thanks.

 
I think that this would work:

[tab][COLOR=blue white]=Max(EOMonth(DateSelected,-5), MIN(MyDates))[/color]

[tt][blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 


Sleek 'n' slick!

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top