按时间段查询记录的语句怎么写?

miaomiao521 2004-01-18 11:16:15
ASP+Access数据库~要查表[booking]中的[date]字段中日期值为昨天10:00到今日10:00之间的记录~不足的就查到目前为止~
date中的记录格式为2004-1-10 12:43:22~

比如现在是2004-1-10 8:33:22,那么要查的就是 2004-1-9 10:00:00 到2004-1-10 8:33:22只见的记录~
如果现在是2004-1-14 20:43:12,那么要查的是 2004-1-13 10:00:00 到2004-1-14 10:00:00~~

谢谢各位~

http://expert.csdn.net/Expert/topic/2664/2664499.xml?temp=5.251712E-02
一些参考~
...全文
110 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
miaomiao521 2004-02-03
  • 打赏
  • 举报
回复
Dim H, D1, D2, SQL
H = Hour(Now)
D1= dateadd("d", -1, date) & " 10:00:00"
if H < 10 then
D2 = Now
else
D2 = Date & " 10:00:00"
end if

SQL = "select * from [booking] where 预约确认时间 between #"+ D1 +"# and #"+ D2 +"#"

response.write SQL
rs.open SQL,conn,1,3

输出结果:

select * from [booking] where 预约确认时间 between #2004-2-2 10:00:00# and #2004-2-3 10:00:00#
Microsoft JET Database Engine 错误 '80040e10'

至少一个参数没有被指定值。

/blt/admin/NewBook.asp,行 46

======================
怎么换SQL语句它还是'80040e10' 这个错误,至少一个参数没有被指定~
我想可能不是SQL语句的问题,使我IIS哪里没有设置好?还是ACCESS数据库哪里没有设置好?

wumu8488 2004-01-26
  • 打赏
  • 举报
回复
试一试 鱼在树梢的
up
starboy1413 2004-01-26
  • 打赏
  • 举报
回复
between...and......
TrueAndFalse 2004-01-26
  • 打赏
  • 举报
回复
d1=dateadd("d",-1,date())&" 10:00:00"
d2=date()&" 10:00:00"
sql = "select * from table where date between #"&d1&"# and #"&d2&"#"
简易无忌 2004-01-26
  • 打赏
  • 举报
回复
大家也许没闹明白他想要什么,看看下面是不是你要的(T_qwe是你的表, RQ是你的Date字段)

select * from T_qwe where RQ between (dateadd('d',-1,date()) & ' 10:00:00') and (date() & ' 10:00:00')
miaomiao521 2004-01-26
  • 打赏
  • 举报
回复
upup~
zty0527 2004-01-18
  • 打赏
  • 举报
回复
select * from table where date between #2003-01-01# and #2004-01-01#
winson79 2004-01-18
  • 打赏
  • 举报
回复
select * from table where date between #2003-01-01# and #2004-01-01#
say1no2 2004-01-18
  • 打赏
  • 举报
回复
d1=#2003-01-01#
d2=#2004-01-01#
sql = "select * from table where date between #"&d1&"# and #"&d2&"#"
xieyj 2004-01-18
  • 打赏
  • 举报
回复
select * from table where date between #2003-01-01# and #2004-01-01#
TrueAndFalse 2004-01-18
  • 打赏
  • 举报
回复
Access数据库的日期格式要加#
顶一下
aspnetxp 2004-01-18
  • 打赏
  • 举报
回复
弟兄们,赶紧回家吧,大过年的...
aspnetxp 2004-01-18
  • 打赏
  • 举报
回复
大过年的...
紫玄青 2004-01-18
  • 打赏
  • 举报
回复
select * from table where date>=#2003-01-01 and date<=2004-1-1
这样有没有什么意外会发生?
aspnetxp 2004-01-18
  • 打赏
  • 举报
回复
select * from table where date between #2003-01-01# and #2004-01-01#
试一试,可以了吧?
紫郢剑侠 2004-01-18
  • 打赏
  • 举报
回复
up

28,406

社区成员

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

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