| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1244 人关注过本帖
标题:[求助]时间段查询问题
只看楼主 加入收藏
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
结帖率:68.57%
收藏
 问题点数:0 回复次数:10 
[求助]时间段查询问题
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> <!--#include file = "checkinfoadmin.asp"--> <!-- #include file="conn.asp" --> <html> <style type="text/css"> <!-- .style18 {color: #330000} --> </style> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>:::清单:::</title> <link href="../css/fontsize.css" rel="stylesheet" type="text/css"> <link href="../css/input_form.css" rel="stylesheet" type="text/css"> <link href="../css/inputform1.css" rel="stylesheet" type="text/css"> <link href="../css/selectform.css" rel="stylesheet" type="text/css"> <link href="../css/inputform2.css" rel="stylesheet" type="text/css"> <link href="../css/inputform3.css" rel="stylesheet" type="text/css"> <link href="../css/inputform3.css" rel="stylesheet" type="text/css"> <link href="../css/link.css" rel="stylesheet" type="text/css"> <link href="../css/buttoncss.css" rel="stylesheet" type="text/css"> <link href="../css/inputchaxun.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- body { background-image: url(../pictures/0343.jpg); } .style6 {color: #66CCFF} .style7 { color: #330000; font-style: italic; } .style8 {font-size: 12pt} .style10 { color: #330000; font-size: 16px; } .style11 {color: #0000FF} .style13 {font-size: 14px} .style15 {font-size: 16px} .style19 {color: #990000} .style21 { color: #0000FF; font-size: 18px; font-weight: bold; font-style: italic; } .style23 { color: #66CCFF; font-weight: bold; font-style: italic; } .style25 {color: #0000FF; font-size: 18px; font-weight: bold; } .style26 {color: #660000; } --> </style></head> <body bgcolor="#6699cc" > <tr> <td width="100%" height="71" background="../pictures/0343.jpg"><font color="#660000">&nbsp;&nbsp;:::欢迎您使用本查询模块:::请输入查询条件...</font> </td> </tr> <tr> </td></tr> <tr> <td background="../pictures/0343.jpg"><div align="right"> <table width="760" height="27" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#333300" bgcolor="#FFFFFF" class="fontsize" style="border-collapse: collapse"> <form name="chaxun_form" action="fineschool.asp" method="post" > <tr align="center" valign="middle"> <td width="7%" height="23" bgcolor="#66CCCC"> <div align="center">公司</div></td> <td width="9%"><div align="center"><font size="2"> <input name="school_chaxun" type="text" id="school_chaxun2" onMouseOver="this.focus();" size="5"> </font></div></td> <td width="7%" bgcolor="#66CCCC"> <div align="center"><font size="2">单号 </font></div></td> <td width="16%" bgcolor="#FFFFFF"><div align="center"> <input name="num_of_grade_chaxun" type="text" id="num_of_grade_chaxun"onMouseOver="this.focus();" size="11"> </div></td> <td width="7%" bgcolor="#66CCCC"> <div align="center">起期</div></td> <td width="12%"> <div align="center"> <input name="starttime_chaxun" type="text" id="starttime_chaxun" onMouseOver="this.focus();" value="<%=date()-30%>" size="8"> </div></td> <td width="7%" bgcolor="#66CCCC"> <div align="center">终期</div></td> <td width="12%"> <div align="center"> <input name="endtime_chaxun" type="text" id="endtime_chaxun" onMouseOver="this.focus();" value="<%=date()%>" size="8"> </div></td> <td width="7%" bgcolor="#66CCCC"> <div align="center"><font size="2">类型</font></div></td> <td width="6%"> <div align="center"><font size="2"> <input name="num_of_classes_chaxun" type="text" id="num_of_classes_chaxun"onMouseOver="this.focus();" size="2"> </font></div></td> <td width="7%" bgcolor="#66CCCC">备注</td> <td width="14%" bgcolor="#66CCCC"><font size="2"> <input name="num_of_bz_chaxun" type="text" id="num_of_bz_chaxun2" onMouseOver="this.focus();" size="5"> </font></td> <td width="14%" bgcolor="#66CCCC"> <div align="center"> <input name="chaxun" type="submit" id="chaxun5" value="我要查询"> </div></td> </tr> </form> </table> </div> </td> </tr> <tr> <td background="../pictures/0343.jpg">&nbsp;</td> </tr> <tr> <td background="../pictures/0343.jpg"><div align="right"><span class="style13">办理人员:<span class="style19"><%=session("name")%></span></span><span class="style19"></span><span class="style18"></span>&nbsp;&nbsp;</div></td> </tr> <tr> <td background="../pictures/0343.jpg"><div align="left"><font color="#660000">&nbsp;&nbsp;下表是查询结果清单:</font></div></td> </tr> <tr> <td height="141" background="../pictures/0343.jpg"> <table width="760" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#333300" bgcolor="#66CCCC" style="border-collapse: collapse"> <tr align="center" valign="middle" bgcolor="#FFCCCC" class="fontsize"> <td width="15%" height="27"> <div align="center"><strong>发件公司</strong></div></td> <td width="9%"><div align="center"><strong>发件人</strong></div></td> <td width="9%"> <div align="center"><strong>发件日期</strong></div></td> <td width="13%"> <div align="center"><strong>单号</strong></div></td> <td width="5%"> <div align="center"><strong>类型</strong></div></td> <td width="5%"> <div align="center"><strong>重量</strong></div></td> <td width="5%"> <div align="center"><strong>金额</strong></div></td> <td width="15%"> <div align="center"><strong>收件公司地址</strong></div></td> <td width="9%"> <div align="center"><strong>收件人</strong></div></td> <td width="11%"> <div align="center"><strong>备注</strong></div></td> </tr> <% set rs=server.CreateObject("adodb.recordset") if request("starttime_chaxun")="" and request("endtime_chaxun")="" then sql= "select * from school where school like '%"&trim(request("school_chaxun"))&"%'and num_of_classes like '%"&trim(request("num_of_classes_chaxun"))&"%' and num_of_grade like'%"&trim(request("num_of_grade_chaxun"))&"%'and num_of_bz like'%"&trim(request("num_of_bz_chaxun"))&"%' order by num_of_riqi desc" else sql="select * from school where num_of_riqi between #"&cdate(request("starttime_chaxun"))&"# and #"&cdate(request("endtime_chaxun"))&"# and school like '%"&trim(request("school_chaxun"))&"%'and num_of_classes like '%"&trim(request("num_of_classes_chaxun"))&"%' and num_of_grade like'%"&trim(request("num_of_grade_chaxun"))&"%'and num_of_bz like'%"&trim(request("num_of_bz_chaxun"))&"%' order by num_of_riqi desc " end if rs.open sql,conn,1,1 if rs.recordcount <> 0 then rs.movefirst do while not rs.eof %> <tr bgcolor="#66CCCC" class="fontsize"> <td><div align="center"><%=rs("school")%></div></td> <td><div align="center"><%=rs("num_of_fjr")%></div></td> <td><div align="center"><%=rs("num_of_riqi")%></div></td> <td><div align="center"><%=rs("num_of_grade")%></div></td> <td><div align="center"><%=rs("num_of_classes")%></div></td> <td height="28"><div align="center"><%=rs("num_of_students")%></div></td> <td><div align="center"><%=rs("num_of_je")%></div></td> <td><div align="center"><%=rs("num_of_fjd")%></div></td> <td><div align="center"><%=rs("num_of_sjr")%></div></td> <td><div align="center" class="style26"><%=rs("num_of_bz")%></div></td> </tr> <% rs.movenext loop else %> <tr class="fontsize"> <td height="24" colspan="7" bgcolor="#66CCCC"><div align="center" class="style11"><font size="2">对不起,没查询到符合您需要的信息!</font></div></td> </tr> <% end if %> </table> <p>&nbsp;&nbsp;<span class="style6"><span class="style7 style15">合计:&nbsp;&nbsp;总件数为:<span class="style25"><%=rs.recordcount%>&nbsp;</span>件; &nbsp;&nbsp; <% dim toutput'设置变量,总重量合计初始值为0 num_of_students="" toutput=0 set rs=server.CreateObject("adodb.recordset") if request("starttime_chaxun")="" and request("endtime_chaxun")="" then sql= "select * from school where school like '%"&trim(request("school_chaxun"))&"%'and num_of_classes like '%"&trim(request("num_of_classes_chaxun"))&"%' and num_of_grade like'%"&trim(request("num_of_grade_chaxun"))&"%'and num_of_bz like'%"&trim(request("num_of_bz_chaxun"))&"%' order by num_of_riqi desc" else sql="select * from school where num_of_riqi between #"&cdate(request("starttime_chaxun"))&"# and #"&cdate(request("endtime_chaxun"))&"# and school like '%"&trim(request("school_chaxun"))&"%'and num_of_classes like '%"&trim(request("num_of_classes_chaxun"))&"%' and num_of_grade like'%"&trim(request("num_of_grade_chaxun"))&"%'and num_of_bz like'%"&trim(request("num_of_bz_chaxun"))&"%' order by num_of_riqi desc " end if rs.open sql,conn,1,1 if not rs.eof then %> <% while not rs.eof if num_of_students<>rs("num_of_students") then '写入重量 num_of_students=rs("num_of_students") toutput=toutput+0 %> <% end if%> <% toutput=toutput+(rs("num_of_students")) 'cint 取整数 rs.movenext if rs.eof then %> <% end if wend %> <% end if %> 总重量为:<span class="style25"><%=toutput-0%>&nbsp;</span>KG;&nbsp;&nbsp; <% dim toutputa num_of_je="" toutputa=0 set rs=server.CreateObject("adodb.recordset") if request("starttime_chaxun")="" and request("endtime_chaxun")="" then sql= "select * from school where school like '%"&trim(request("school_chaxun"))&"%'and num_of_classes like '%"&trim(request("num_of_classes_chaxun"))&"%' and num_of_grade like'%"&trim(request("num_of_grade_chaxun"))&"%'and num_of_bz like'%"&trim(request("num_of_bz_chaxun"))&"%' order by num_of_riqi desc" else sql="select * from school where num_of_riqi between #"&cdate(request("starttime_chaxun"))&"# and #"&cdate(request("endtime_chaxun"))&"# and school like '%"&trim(request("school_chaxun"))&"%'and num_of_classes like '%"&trim(request("num_of_classes_chaxun"))&"%' and num_of_grade like'%"&trim(request("num_of_grade_chaxun"))&"%'and num_of_bz like'%"&trim(request("num_of_bz_chaxun"))&"%' order by num_of_riqi desc " end if rs.open sql,conn,1,1 if not rs.eof then %> <% while not rs.eof if num_of_je<>rs("num_of_je") then '写入重量 num_of_je=rs("num_of_je") toutputa=toutputa+0 %> <% end if%> <% toutputa=toutputa+(rs("num_of_je")) 'cint rs.movenext if rs.eof then %> <% end if wend %> <% end if %> 总金额为:</span></span><span class="style21"><%=toutputa-0%>&nbsp;</span><span class="style23"><span class="style15 style18"><span class="style11"></em></span></span></span><span class="style10 style8"><strong><span class="style15"><em></em></span></strong><em>元</em></span> </p> </tr> <p> <% rs.close set rs = nothing conn.close set conn = nothing %> </p> <p>&nbsp;</p> <p>&nbsp; </p> <p align="right"><span class="style6"><span class="style7"><span class="style8">:::我的查询</span>:::<span class="style15"></span>&nbsp;&nbsp;</span></span></p> </body> </html>我想查询公司名是“某某”在某段时间所发生的事情。但是在时间段的查询出现了错误了。哥们能否详细的给段类似代码的例子为谢!

[此贴子已经被作者于2005-8-17 18:16:17编辑过]

搜索更多相关主题的帖子: css 时间段 text rel 
2005-08-17 18:13
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
你想做什么?
如果是错误
请把错误信息写出来

2005-08-18 08:43
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
收藏
得分:0 
我明白了,但是我不会..

面朝大海,春暖花开!
2005-08-18 09:05
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
那么多代码
看都看累了
给出相关信息看起来也简单一点啊

[此贴子已经被作者于2005-8-18 9:20:18编辑过]



2005-08-18 09:19
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
收藏
得分:0 
[求助]时间段查询问题?困我好久了,帮个忙
没有错误信息提示!但是查询结果得不到我想要的结果,看上面我的运行代码,比如,我想查询公司(gongsi)为“天天”,在起日期2005-7-1(起期为starttime)到终日期2005-7-10( 终期为engtime)之间的所有类型(leixing)为“到付”的所有项,我的SQL是以下这样写的:(虽然查出来了,但是要在1号到9号的时候没有错,但是,有10号以上的查询时就得不到我要的结果了,比如说:我查询公司为“天天”在起日期2005-7-1到终日期2005-7-10之间的所有类型(leixing)为“到付”的所有项,出来的结果是:只有7月1号和7月10号的所有符合条件的项,而7月2号到7月9号的数据没有,但是如果我查的是2005-7-1到2005-7-9的时候,是完全符合条件的。) 表名为:JINFEI 属性有:GONGSI LEIXING RIQI BZ 公司 类型 日期 备注 输入窗口对应的有: GONGSI_CHAXUN LEIXING_CHAXUN RIQI (startime_chaxun和engtime_chaxun) BZ_CHAXUN SQL语句为: <% set rs=server.CreateObject("adodb.recordset") if request("starttime_chaxun")="" and request("endtime_chaxun")="" then SQL= "select * from JINFEI where GONGSI like '%"&trim(request("GONGSI _chaxun"))&"% and LEIXING like'%"&trim(request("LEIXING_chaxun"))&"%'and BZ like'%"&trim(request("BZ_chaxun"))&"%' order by ID desc" else sql="select * from JINFEI where RIQI between #"&cdate(request("starttime_chaxun"))&"# and #"&cdate(request("endtime_chaxun"))&"# and GONGSI like '%"&trim(request("GONGSI_chaxun"))&"%'and LEIXING like '%"&trim(request("LEIXING_chaxun"))&"%' and BZ like'%"&trim(request("BZ_chaxun"))&"%' order by ID desc " end if rs.open sql,conn,1,1 if rs.recordcount <> 0 then rs.movefirst do while not rs.eof %> 有类似的例子吗?发一个为谢!!

[此贴子已经被作者于2005-8-18 11:36:09编辑过]


我是农家的孩子,我有农家孩子的本色!
2005-08-18 10:52
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
收藏
得分:0 
如有类似例子的哥们!发一个为谢!

我是农家的孩子,我有农家孩子的本色!
2005-08-18 12:16
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
收藏
得分:0 
求求帮个忙了哥们!急呢!
先谢谢了。

我是农家的孩子,我有农家孩子的本色!
2005-08-19 12:35
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
收藏
得分:0 
[CODE]<% set rs=server.CreateObject("adodb.recordset") if request("starttime_chaxun")="" and request("endtime_chaxun")="" then SQL= "select * from JINFEI where GONGSI like '%"&trim(request("GONGSI _chaxun"))&"% and LEIXING like'%"&trim(request("LEIXING_chaxun"))&"%'and BZ like'%"&trim(request("BZ_chaxun"))&"%' order by ID desc" else sql="select * from JINFEI where RIQI between #"&cdate(request("starttime_chaxun"))&"# and #"&cdate(request("endtime_chaxun"))&"# and GONGSI like '%"&trim(request("GONGSI_chaxun"))&"%'and LEIXING like '%"&trim(request("LEIXING_chaxun"))&"%' and BZ like'%"&trim(request("BZ_chaxun"))&"%' order by ID desc " end if rs.open sql,conn,1,1 if rs.recordcount <> 0 then rs.movefirst do while not rs.eof %> [/CODE]

我是农家的孩子,我有农家孩子的本色!
2005-08-19 15:18
anjincheng
Rank: 2
等 级:论坛游民
威 望:5
帖 子:728
专家分:31
注 册:2005-7-27
收藏
得分:0 
求求帮个忙了哥们!急呢!
先谢谢了。

我是农家的孩子,我有农家孩子的本色!
2005-08-20 14:55
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
实在不行你就在查询时把所有日期转成长整clng(date())看看行不
2005-08-20 14:59
快速回复:[求助]时间段查询问题
数据加载中...
 
   



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

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