注册 登录
编程论坛 ASP技术论坛

关于按时间查询的问题

munaiyi 发布于 2008-05-19 20:45, 635 次点击
我数据库的时间是按now()获取的,现在表单传过来的值是2008-08-08这样的格式,
请问我如何按时间查询数据库中的值。
time1 和time2是传过来的两个时间,我要查询这个时间段的数据。
t_time=datediff("d",time1,time2)
select id,pno,number,num,categoryid from products where 1=1 and pno='0002' and datediff('d',senddate,time2)<=&t_time and datediff('d',senddate,time2)>0 order by categoryid desc
1 回复
#2
madpbpl2008-05-19 22:05
acc还是mssql?
acc
select id,pno,number,num,categoryid from products where 1=1 and pno='0002' and senddate between #"&time1&"# and #"&time2&"# order by categoryid desc

mssql
select id,pno,number,num,categoryid from products where 1=1 and pno='0002' and senddate between '"&time1&"' and '"&time2&"' order by categoryid desc
1