Norman,
Just played around some more with Jason's formula. Originally, I tested it
exactly as Jason had entered it
=SUMPRODUCT((A1:A300>="4/1/04"*1)*(A1:A300<="4/7/04"*1))
and with my test data it returned a 2. But of course, Jason is American, so
he was talking 1st April to 7th April. I got the 'correct' answer, so I
assumed Excel defaulting to US style dates. So I then change the formula,
but not the data, to
=SUMPRODUCT((A1:A300>="1/4/04"*1)*(A1:A300<="7/4/04"*1))
and it still returned the same answer. The problem obviously was inadequate
test data was insufficient, just 2 dates to prove it
added up, so I added another of 8th April, and Jason's version returned 3,
mine returned 2, which was correct.
So, Jason's version suffers from the old US/European date problem, and as it
stands can not be offered as a solution as the poster could be using either
format. Of course, the DATE(year,month,day) problem does not suffer from
this.
The obvious solution is to suggest putting the date in a cell and compare
against that, but that is always satisfactory, sometimes it is good to have
the date in the formula. On this basis, I suggest the following version,
which although I can't test with US dates, I would assume works okay with
both date styles
=SUMPRODUCT((A1:A300>="01-Apr-2004"*1)*(A1:A300<="07-Apr-2004"*1))
This can be made more flexible to cater for a fixed date in the current
year with
=SUMPRODUCT((A1:A300>=("01-Apr-"&YEAR(TODAY()))*1)*(A1:A300<=("07-Apr-"&YEAR
(TODAY()))*1))
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)