时间段查询的问题?急啊在线等啊!
id Atime Btime Cname
1 2007-6-29 10:44:00 2007-6-29 10:50:00 时间查1
2 2007-6-29 11:02:00 2007-6-29 11:20:00 时间查1
怎么用服务器时间查atime到btime所显示的信息
比如现在是2007-6-29 11:12:00
就可以显示出第2条信息
我要怎么写我写的却不对
itime=CDate(Now())
set rs= server.createobject ( "adodb.recordset ")
sql= "select * from SysAds where Atime > ' "&itime& " ' and Btime < ' "&itime& " ' "
rs.open sql,conn,1,1
Response.Write ( "数据库显示: "&rs( "Timefrom ")& "- "&rs( "Timeto ")& " ")
------解决方案--------------------sql= "select * from SysAds where Atime > ' "&itime& " ' and Btime < ' "&itime& " ' "
sql= "select * from SysAds where datediff(d,atime, ' "&itme& " ') <0 and datediff(d,btime, ' "&itime& " ')> 0
------解决方案--------------------itime=Now()
set rs= server.createobject ( "adodb.recordset ")
sql= "select * from SysAds where Atime > # "&itime& "# and Btime < # "&itime& "# "
rs.open sql,conn,1,1
Response.Write ( "数据库显示: "&rs( "Atime ")& "- "&rs( "Btime "))
------解决方案--------------------select * from SysAds where getdate() between Atime and Btime
------解决方案--------------------我经常用,应该可以的:
sql= "select * from SysAds where DateDiff( 'd ',now,atime)> =0 and DateDiff( 'd ',now,btime) <=0 "
atime和btime应该是时间格式。
------解决方案--------------------up