日期查询类型不匹配

rcsglydm 2009-08-13 08:15:27
第一个页面提供“开始日期”和“结束日期”,日期格式为2009-1-1。
下一个页面根据日期进行查询。
time1=request("time1")
time2=request("time2")
sql=select * from worklist where time>'"&time1&"' and time<'"&time2&"'" //此处,提示表达式中类型不匹配
rs.open sql,conn,1,3

请高手帮助。
...全文
44 点赞 收藏 5
写回复
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
toury 2009-08-13
sql="SELECT * FROM worklist WHERE time BETWEEN #"&time1&"# and #"&time2&"#"
回复
hookee 2009-08-13
access

sql="select * from worklist where DateDiff('d',[time],#" & time1 &"#)<0 AND DateDiff('d',[time],#" & time2 & "#)>0"

回复
rcsglydm 2009-08-13
是在ACCESS中,字段为“日期/时间”。
回复
hookee 2009-08-13
改下
sql server 
sql="select * from worklist where DateDiff(d,[time],'" & time1 &"')<0 AND DateDiff(d,[time],'" & time2 & "')>0"

access
sql="select * from worklist where DateDiff('d',[time],#" & time1 &"#)<0 AND DateDiff('d',[time],#" & time2 & "#)>0"

回复
hookee 2009-08-13
sql server
sql="select * from worklist where DateDiff(d,[time],'" & time1 &"')<0 AND DateDiff(d,[time],'" & time2 & "'>0)"

access
sql="select * from worklist where DateDiff('d',[time],#" & time1 &"#)<0 AND DateDiff('d',[time],#" & time2 & "#>0)"

回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告