数据库中利用日期查询请教个位高手

pcwanli 2003-10-15 03:17:35
我的查询语句是这样的怎么就是不对:
set rs = server.createobject("adodb.recordset")
rs.CursorLocation = 3
rs.Open "select * from table where subdate between #2002-01-01# and #2003-12-30#",conn,2
问题好象就是出在SQL语句中,数据库是SQL SERVER,subdate字段的类型是datetime类型,此类型有日期和时间如2003-9-25 10:09:26。各位高手帮忙,怎样查询日期在2002-01-01到2003-12-30之间的数据,是“#”符号不对,还是类型的问题,还是什么其他的问题?先谢谢各位了。
...全文
78 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
angeb 2003-10-15
  • 打赏
  • 举报
回复
#是access数据库用的
angeb 2003-10-15
  • 打赏
  • 举报
回复
set rs = server.createobject("adodb.recordset")
sql= "select * from table where subdate between '2002-01-01' and '2003-12-30' "
rs.Open sql,conn,1,1
zhanghao5188 2003-10-15
  • 打赏
  • 举报
回复
rs.open "select * from biao where subdate >='2002-01-01 00:00:00' and subdate<='2003-12-30 23:59:59'",conn,1,3 在sql 中


rs.Open "select * from biao where subdate between #2002-01-01# and #2003-12-30#",conn,1,3 在access中没有问题!
1蓝天1 2003-10-15
  • 打赏
  • 举报
回复
在两个日期之间的话只要加个AND在把=号一改就可了
1蓝天1 2003-10-15
  • 打赏
  • 举报
回复
我的是这样写的,用起来很好用呀!试试吧
sql = "select * from gzwt where account='"&account&"' and wt_time=#"×&"#"
shiyudir12 2003-10-15
  • 打赏
  • 举报
回复
"select * from table where subdate >=#2002-01-01 00:00:00# and subdate<=#2003-12-30 23:59:59#"
say1no2 2003-10-15
  • 打赏
  • 举报
回复
"select * from table where subdate > '2002-01-01' and subdate < '2003-12-30'"
lovehwq21 2003-10-15
  • 打赏
  • 举报
回复
"select * from table where subdate >='2002-01-01 00:00:00' and subdate<='2003-12-30 23:59:59'"
shijian58 2003-10-15
  • 打赏
  • 举报
回复
输出你的sql语句到数据库里试一下不久知道了吗
gshope 2003-10-15
  • 打赏
  • 举报
回复
select * from table where subdate>'2002-01-01' and subdate<dateadd(dd,1,'2003-12-30')

28,390

社区成员

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

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