| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 382 人关注过本帖
标题:[求助] 统计信息不准确.急!
只看楼主 加入收藏
lcd2105
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2006-8-22
收藏
 问题点数:0 回复次数:4 
[求助] 统计信息不准确.急!

各位老师:
  烦请帮看一下以下代码为何在根据时间段统计时不准确?
我用了循环语句(红色)错在哪,请帮指点,为感!

<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
do while not rs.eof
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.movenext
loop
RS.CLOSE

sqlstr="select * from news where xxtype='B' and author='一部'"
rs.Open sqlstr,connstr,1,3
do while not rs.eof
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.movenext
loop

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>

搜索更多相关主题的帖子: 统计 border center 时间段 
2006-08-22 15:21
seal520_2008
Rank: 1
等 级:新手上路
帖 子:239
专家分:0
注 册:2006-6-13
收藏
得分:0 
你这里的循环用意是什么呢???

每晚0:00上线 msn:seal520_2008@ myblog:http://seal.
2006-08-22 15:32
hangxj
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2045
专家分:0
注 册:2006-4-10
收藏
得分:0 
你写的程序谁都不会知道你要实现的是什么功能,所以下次麻烦你顺便说一下你这段代码要实现的是什么功能,以及出现的问题.

http://www./
2006-08-22 15:39
lcd2105
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2006-8-22
收藏
得分:0 
循环读出数据库中的所有数据呀,不对吗?

在统计中按时间段如果是从第一天到最后一天,那读出来的数据的正确的;如果是某一天或者某个时间段,那读出来的数据的不正确.

我数据库中的时间格式的2006-8-8 10:11:12 。我已将时间格式改为2006-8-8 用这句子代码是否正确?
year(rs("updatetime")) &amp; "-" &amp; month(rs("updatetime")) &amp; "-" &amp; day(rs("updatetime"))
2006-08-22 15:46
lcd2105
Rank: 1
等 级:新手上路
帖 子:41
专家分:0
注 册:2006-8-22
收藏
得分:0 
我这个程序最终显示的页面例:

         统计日期从2006-08-01至2006-08-02

     单位  A类信息    B类信息    总篇数   总分
     一部     4         5          10       19


出现的问题是:
   按时间段如果是从第一天到最后一天,那读出来的数据的正确的;如果是某一天或者某个时间段,那读出来的数据的不正确.
2006-08-22 15:54
快速回复:[求助] 统计信息不准确.急!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022266 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved