帮忙看看这个SQL语句的错误~~~~~~~~先谢谢了!

fluterheart 2004-06-08 10:21:30
SQL字段类型是datetime型,表的字段是submit_time我在前台提供了时间段查询,但页面显示错误:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
/efy/delator/admin/sch.asp, 第 61 行---------这个行是:


zrs.open"SELECT * FROM informations where jbbm='"&jbbm&"' and xianshi='否' and submit_time between #date1# and #date2# ORDER BY submit_time desc ",zcon,1,1


我在前台是这样得到的时间串实现的:

jbbm = session("jbbm")
date1 = request.Form("y1")&"-"&request.Form("y2")&"-"&request.Form("y3")
date2 = request.Form("y3")&"-"&request.Form("y4")&"-"&request.Form("y5")
if jbbm <> "" then
zrs.open"SELECT * FROM informations where jbbm='"&jbbm&"' and xianshi='否' and submit_time between #date1# and #date2# ORDER BY submit_time desc ",zcon,1,1



帮忙分析错误,请改正
...全文
85 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxty 2004-06-08
  • 打赏
  • 举报
回复
不要#号
weige250 2004-06-08
  • 打赏
  • 举报
回复
QCB181 2004-06-08
  • 打赏
  • 举报
回复
SELECT * FROM informations where jbbm='"&jbbm&"' and xianshi='否' and submit_time > #date1# and submit_time<#date2# ORDER BY submit_time desc
  • 打赏
  • 举报
回复
同意楼上
amadou 2004-06-08
  • 打赏
  • 举报
回复
date1 = cdate(request.Form("y1")&"-"&request.Form("y2")&"-"&request.Form("y3"))
date2 = cdate(request.Form("y3")&"-"&request.Form("y4")&"-"&request.Form("y5"))
angelheavens 2004-06-08
  • 打赏
  • 举报
回复
jbbm = session("jbbm")
'转换时确保各参数值是数字,否则出错
date1 = CDate(request.Form("y1")&"-"&request.Form("y2")&"-"&request.Form("y3"))
date2 = CDate(request.Form("y3")&"-"&request.Form("y4")&"-"&request.Form("y5"))
if jbbm <> "" then
zrs.open "SELECT * FROM informations where jbbm='"&jbbm&"' and xianshi='否' and DateDiff('d',submit_time,'"&date1&"')>=0 and DateDiff('d',submit_time,'"&date2&"')<=0 ORDER BY submit_time desc ",zcon,1,1
wesheng 2004-06-08
  • 打赏
  • 举报
回复
目前取得的date1,date2是字符类型的.你可以试试将其转化为DATE类型
ttt2 2004-06-08
  • 打赏
  • 举报
回复
jbbm = session("jbbm")
date1 = request.Form("y1")&"-"&request.Form("y2")&"-"&request.Form("y3")
date2 = request.Form("y3")&"-"&request.Form("y4")&"-"&request.Form("y5")
if jbbm <> "" then
zrs.open"SELECT * FROM informations where jbbm='"&jbbm&"' and xianshi='否' and submit_time between '"&date1&' and '"&date2&"' ORDER BY submit_time desc ",zcon,1,1
ling_l 2004-06-08
  • 打赏
  • 举报
回复
你把字段改date

28,404

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧