完美国际熊猫变狐狸变:asp中如何使用sql语句对数据库进行时间段的条件查询

来源:百度文库 编辑:神马品牌网 时间:2024/04/28 19:36:33
<%
vtime1=date()-30
vtime2=date()
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from clgl where 数据库字段(time)“sql条件查询的语句”,conn
%>
sql的条件查询是:数据库中time字段在vtime1和vtime2之间
急需答案,请大家帮帮忙,谢谢!!
两个方法都用了,第一个不显示,第二个只读出一条与数据库匹配的记录,使用了do while not rs.eof .... rs.movenext loop,数据库中time字段是日期型的,读的时候报错数据类型不匹配.

select * from clgl where time between vtime1 and vtime2

select * from clgl where time >= #"&vtime1&"# and time <= #"&vtime2&"#"

时间范围是包含vtime1和vtime2的

我要提醒的是,between...and...只能用于INT型的数据,如果是字符类型的就注意加单引号

只读出一条是不是因为你没有循环读啊:while not rs.eof...