烦请帮看一下以下代码,为何在统计中按日期段如果是从第一天到最后一天,统计出来的数据是准确的;而某一天或者某个时间段,统计出来的数据不准确?
我数据库中的时间格式的2006-8-8 10:11:12 。现用了这句代码:year(rs("updatetime")) & "-" & month(rs("updatetime")) & "-" & day(rs("updatetime")) 将时间格式改为2006-8-8 , 是否正确?
请帮指点,为感!
<body>
<table border="1" width="649" id="table1" height="280">
<tr>
<td width="123" align="center" colspan="2" height="13"><font size="2">单位</font></td>
<td width="50" align="center" height="13"><font size="2">A类信息</font></td>
<td width="51" align="center" height="13"><font size="2">B类信息</font></td>
<td width="43" align="center" height="13"><font size="2">总篇数</font></td>
<td width="55" align="center" height="13"><font size="2">总分</font></td>
</tr>
<% set rs=server.CreateObject("adodb.recordset")
sqlstr="select * from news where xxtype='A' and author='一部'"
rs.Open sqlstr,connstr,1,3
if cdate(year(rs("updatetime")) & "-" & month(rs("updatetime")) & "-" & day(rs("updatetime")))>=cdate(dateb1) and cdate(year(rs("updatetime")) & "-" & month(rs("updatetime")) & "-" & day(rs("updatetime")))<=cdate(dateb2) then
yba=RS.RECORDCOUNT
ybsa=yba*1
end if
RS.CLOSE
sqlstr="select * from news where xxtype='B' and author='一部'"
rs.Open sqlstr,connstr,1,3
if cdate(year(rs("updatetime")) & "-" & month(rs("updatetime")) & "-" & day(rs("updatetime")))>=cdate(dateb1) and cdate(year(rs("updatetime")) & "-" & month(rs("updatetime")) & "-" & day(rs("updatetime")))<=cdate(dateb2) then
ybb=RS.RECORDCOUNT
ybsb=ybb*3
end if
RS.CLOSE
if yba ="" then yba ="0"
if ybb ="" then ybb ="0"
%>
<tr>
<td width="41" valign="middle" align="center" rowspan="5" height="96"><font size="2">一队</font></td>
<td width="77" valign="middle" align="center" height="21"><font size="2">一部</font></td>
<td width="50" valign="middle" align="center" height="21"><font size="2"><%=yba%></font></td>
<td width="51" valign="middle" align="center" height="21"><font size="2"><%=ybb%> </font></td>
<td width="43" valign="middle" align="center" height="21"><font size="2"><%=yba+ybb%></font></td>
<td width="55" valign="middle" align="center" height="21"><font size="2"><%=ybsa+ybsb%></font></td>
</tr>
</body>