If statment

J

Jason

I am trying to write and if statment to include only 2001 dates. However, I
have dates both in 2000 and 2002. I tried the writing the following statment
and excel keeps giving me an error:

=IF(Date Field>=1/1/2000 AND <1/1/2002, TRUE, FALSE)

Apparently excel doesn't like the and part. How can I go about getting
around this or writing the formula with a new word or character that excel
will accept?

Thanks,

jason
 
D

Dave Peterson

One way with the date in A1:

=and(a1>=date(2001,1,1),a1<=date(2001,12,31)

or
=year(a1)=2001

You don't need the If's for either of these two formulas. These return true or
false by themselves.
 
S

Sandy Mann

=IF(AND(Date Field>=DATE(2000,1,1),Date Field<DATE(2001,1,1)),TRUE,FALSE)

This assumes that what are calling Date Field is a single cell. If you mean
a range of dates called Date_Field, (you cannot have spaces in a defined
name), then use:

=SUMPRODUCT((Date_Field>=DATE(2000,1,1))*(Date_Field<DATE(2002,1,1)))

Which will count the number of date cells that fall within your required
range.

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings

(e-mail address removed)
Replace @mailinator.com with @tiscali.co.uk
 

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

Similar Threads


Top