Click to See Complete Forum and Search --> : [RESOLVED] Null results? Confused about empty cells.


st3ady
08-08-2006, 12:54 PM
Hey there,

I am working on a report that goes through a big huge database and shows the number of average messages replied to during each hour in a 12 hour day, starting at 6am. It seems there are very few, possibly no messages being replied in the early hours from 6am-7am, and also during 7am-8am. In the cells for these two columns, I get empty cells, when it should be displaying zero. Any idea on how I could catch this? Here is the current code I have:

For i = 0 to 12

If intTime = 18 Then
strBegTime = Cstr("#" & intTime & ":00:00#")
strEndTime = Cstr("#" & intTime + 1 & ":00:00#")
Else
strBegTime = Cstr("#" & intTime & ":00:00#")
strEndTime = Cstr("#" & intTime & ":59:59#")
End If

time_zone = 0

If(District = 8048) Then
time_zone = -0.042 'In access one hour is stored as .042
Elseif(District = 7289) Then
time_zone = 0.042 'In access one hour is stored as .042
Elseif(District = 8158) Then
time_zone = 0.125 '3*0.0147
Else
time_zone = 0
End If


'time_zone = 0
'MinDif = 0
strSQL2="SELECT round(avg(DateDiff('N',[Time Sent],[Time Replied])),2) AS MinDif"_
& " FROM Messages Where [District] = " & District & " AND Messages.[From] Not Like '*To*'"_
& " AND Messages.[Action]='M' AND (Messages.[Time Sent] +"&time_zone & ") < Messages.[Time Replied]"_
& " AND Messages.[Time Sent] < Messages.[Time Replied] AND Date Between #" & start_date & "#"_
& " And #" & end_date &"# And [Time Replied] Between " & strBegTime & " And " & strEndTime & ""_
& " AND Messages.[Time Replied]<>0 AND Messages.[Time Sent]<>0"

'response.write strSQL2
'response.end
rsStatus.Open strSQL2, cnn3, 1, 3

If rsStatus.EOF Then
arMinDif(i) = 0
Else
arMinDif(i) = rsStatus.Fields("MinDif")
End If

If arMinDif(i) = "" Then
arMinDif(i) = 0
End If

intTotalCounter = intTotalCounter + arMinDif(i)

rsStatus.Close

intTime = intTime + 1
Next

If intTotalCounter = 0 Then
MyRSA.MoveNext
Else

%>
<TR>
<TD BGCOLOR="#eeeeff" WIDTH="89" HEIGHT="1"><%=District%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(0)%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(1)%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(2)%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(3)%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(4)%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(5)%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(6)%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(7)%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(8)%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(9)%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(10)%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(11)%></TD>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><%=arMinDif(12)%></TD>
<% totalnumb = 0
totalnumb = ((arMinDif(1)+arMinDif(2)+arMinDif(3)+arMinDif(4)+arMinDif(5)+arMinDif(6)+arMinDif(7)+arMinDif(8)+ar MinDif(9)+arMinDif(10)+arMinDif(11)+arMinDif(12))/12)
'totalnumb = round(totalnumb,2)
%>
<TD BGCOLOR="#eeeeff" WIDTH="50" HEIGHT="1"><B><%=totalnumb%></B></TD>
</TR>

I've tried removing the 6am-7am, and then 7am-8am columns and the whole thing works perfectly. Any ideas? How do I catch null values? I tried:
If rsStatus.fields("MinDif") = NULL Then
arMinDif(i) = 0
End if
But that did not fix it.
Any help would be greatly appreciated :)

russell
08-08-2006, 01:10 PM
If rsStatus.fields("MinDif") = NULL Then


If isNull(rsStatus.fields("MinDif")) Then

st3ady
08-08-2006, 01:56 PM
russell to the rescue! :D
I am still an ASP n00b!! :p