关于查询某个时间段的问题

谁家公子 2007-12-12 11:38:22
像这样写有没有对?
rs.open "select * from shop where (datediff(dd, qytime, '2007-12-1 ') >= 0) and (datediff(dd, '2007-12-12 ', qytime) >= 0) order by shopid desc",conn,1,1
可我这老是读不出数据郁闷了
...全文
80 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
谁家公子 2007-12-12
  • 打赏
  • 举报
回复
select * from shop where qytime > = '2007-12-1' and qytime <= '2007-12-12' order by shopid desc

按你的,还是不行哦
sy_binbin 2007-12-12
  • 打赏
  • 举报
回复
select * from shop where qytime >= '2007-12-1' and qytime <= '2007-12-12'
Go 旅城通票 2007-12-12
  • 打赏
  • 举报
回复
access是##,mssql是''
谁家公子 2007-12-12
  • 打赏
  • 举报
回复
日期要加#才行哦,我搞了好久才好
appleyan 2007-12-12
  • 打赏
  • 举报
回复
select * from shop where qytime >= '" & "2007-12-1" & "' and rq <= '" & "2007-12-12" & "'order by rq desc"
Go 旅城通票 2007-12-12
  • 打赏
  • 举报
回复
mssql数据库还是access的???

access的话为

select   *   from   shop   where   qytime   between   #2007-12-1#   and   #2007-12-12#   order   by   shopid   desc
谁家公子 2007-12-12
  • 打赏
  • 举报
回复
<!--#include file="conn.asp"-->
<%
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from shop where qytime between '2007-12-1' and '2007-12-12' order by shopid desc",conn,1,1
if rs2.eof and rs2.bof then
response.write "暂无数据"
else
do while not rs2.eof
i=i+1%>
<%=rs2("shopname")%>
<%rs2.movenext
loop
end if
rs2.close
set rs2=nothing%>
谁家公子 2007-12-12
  • 打赏
  • 举报
回复
不好意思,按你写的也不行哦
数据库内的日期格式是:
2007-12-3
Go 旅城通票 2007-12-12
  • 打赏
  • 举报
回复
你的sql语句中的条件原来就是一条数据都取不出来的

(datediff(dd, qytime,'2007-12-1') >= 0) 这个是要求qytime<'2007-12-1'
(datediff(dd,'2007-12-12',qytime) >= 0) 这个是要求qytime>'2007-12-12'

这样你能取到数据???????????????

如果你是要查询处于2007-12-1到2007-12-12的数据应该是下面的

select * from shop where qytime between '2007-12-1' and '2007-12-12'
谁家公子 2007-12-12
  • 打赏
  • 举报
回复
大家帮个忙啊,这个问题已经困扰我两天了哦

28,391

社区成员

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

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