# Date Formula with SUMIF

#### DJ'sGiGi

##### Board Regular
Is there a reason Excel won't perform the SUMIF function on a cell with a date formula? In the example below, Excel ignores the SUMIF when I have a formula A6:A18. But if I simply type in values, it calculates fine. My entries are serial dates formatted as a date. I’ve even tried =SUMIF(\$A\$6:\$A\$18,”=”&A6,\$B\$6:\$B\$18) and that doesn’t work either.

<PRE>
9/16/2014 OFF 0.00 "=SUMIF(\$A\$6:\$A\$18,A6,\$B\$6:\$B\$18)"
9/17/2014 0.50 0.50
9/17/2014 0.75 0.75
9/18/2014 0.25 0.25
9/18/2014 0.00
0.00
0.00 </PRE>

Assistance is appreciated.

### Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

#### BiocideJ

##### Well-known Member
If the dates are serial then I suspect the culprit is encoded TIME data.
You can check this by changing the cell formatting to general and see if the value is an INTEGER or if it has decimal information (Decimal values represent times)
If you want to consider 9/17/14 9:00AM equal to 9/17/14 10:00AM then you need to work with the INTEGER portion only with a formula such as the following...

=SUMPRODUCT(--(INT(\$A\$6:\$A\$18)=INT(A7)),\$B\$6:\$B\$18)

• bobsan42

#### DJ'sGiGi

##### Board Regular
If the dates are serial then I suspect the culprit is encoded TIME data.
You can check this by changing the cell formatting to general and see if the value is an INTEGER or if it has decimal information (Decimal values represent times)
If you want to consider 9/17/14 9:00AM equal to 9/17/14 10:00AM then you need to work with the INTEGER portion only with a formula such as the following...

=SUMPRODUCT(--(INT(\$A\$6:\$A\$18)=INT(A7)),\$B\$6:\$B\$18)

BiocideJ,

You are correct, when formatted as general, I get a decimal value. However, your formula returns a #VALUE (even if I enter it as an array.) Also, what does the -- represent between the 2 parens after sumproduct?

Thanks.

#### BiocideJ

##### Well-known Member
If it is giving an error then there must be some non-numeric value in either A6:A18 or B6:B18 which is preventing the SUM portion of the SUMPRODUCT from working.

Also, I noticed that =SUMPRODUCT(--(INT(\$A\$6:\$A\$18)=INT(A7)),\$B\$6:\$B\$18)
should be
=SUMPRODUCT(--(INT(\$A\$6:\$A\$18)=INT(A6)),\$B\$6:\$B\$18)

The -- forces the logical expression (A6:18=A6) to convert from a series of TRUE & FALSE to a series of 1 and 0 so they can be correctly multiplied by the range B6:B18

i.e.
=--TRUE evaluates to 1
and
=--FALSE evaluates to 0

#### DJ'sGiGi

##### Board Regular
If it is giving an error then there must be some non-numeric value in either A6:A18 or B6:B18 which is preventing the SUM portion of the SUMPRODUCT from working.

Also, I noticed that =SUMPRODUCT(--(INT(\$A\$6:\$A\$18)=INT(A7)),\$B\$6:\$B\$18)
should be
=SUMPRODUCT(--(INT(\$A\$6:\$A\$18)=INT(A6)),\$B\$6:\$B\$18)

The -- forces the logical expression (A6:18=A6) to convert from a series of TRUE & FALSE to a series of 1 and 0 so they can be correctly multiplied by the range B6:B18

i.e.
=--TRUE evaluates to 1
and
=--FALSE evaluates to 0

Correct you are sir! The formula stops calculating the date after the end of the billing period. So in effect, it's returning an error. Guess I need to add an if(iserror) statement.

Replies
0
Views
24
Replies
1
Views
64
Replies
12
Views
67
Replies
1
Views
68
Replies
6
Views
83