How do I write an If(And( function using dates as my logical test?

M

mclovin

I'm trying to write a formula which would help me identify all dates within a
month and give me a result that says "July" or "Aug" or whatever.
This is the formula that I tried but didn't work:
=IF(AND(6/30/2009>A1,7/30/2009<=A1),"July")

A B
1 6/30/2009 July
2 7/4/2009 July
3 7/15/2009 July
 
L

Luke M

XL thinks you are inputing division, not dates. Change to:
=IF(AND(DATEVALUE("6/30/2009")>A1,DATEVALUE("7/30/2009")<=A1),"July")

Note that the simpler formula would be to just use
=MONTH(A1)
and custom format the cell as mmmm
 
D

Dave Peterson

Maybe just using:

=text(a1,"mmmm")
would be enough to see the month.

(I'm assuming that you really meant to include July 31st in July, too.)
 
T

T. Valko

=IF(AND(6/30/2009>A1,7/30/2009<=A1),"July")

Can't tell from your formula why you're using those boundaries. If you want
the month name based on any date:

=TEXT(A1,"mmmm")
 
D

Dave Peterson

=MONTH(A1)
will always return a number between 1 and 12.

When you format that cell as "mmmm", you'll always see January.

=A1
formatted to:
mmmm

would work fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top