有个搜索在时间的判断上出现了问题,急救!!!

xiaozhaocnotc 2005-07-11 10:30:54
我有个数据库表,其中有个时间字段,值类型例如:2005-5-1 00:00:00
我现在有个搜索语句:select * from table where sdtime like '"&date()&"%'
不知道这个搜索问题出在哪,望赐教
...全文
83 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
lindy730 2005-07-11
  • 打赏
  • 举报
回复
不可能的,我的在我的网站上试的,可以的
bdb 2005-07-11
  • 打赏
  • 举报
回复
select * from temp where sdtime like #"&date()&"%#
这样可以的。
huangxiaoxia1986 2005-07-11
  • 打赏
  • 举报
回复
set conn=Server.createObject("adodb.connection")创建数据库链接
conn.open "driver={Microsoft Access Driver (*.mdb)};dbq="&Server.mappath("date.mdb")打开
mymonth=month(date())现在时间中的月
myday=day(date())日
set rs=Server.CreateObject("adodb.recordset")
sql="select * from temp where month(date)="&mymonth&" and day(date)="&myday
rs.open sql,conn,3,3
do while not rs.eof
response.write "<table border=1 width=200><tr><Td>id</td><Td>name</td><Td>date</td></tr>"
response.write "<Tr><td>"&rs("id")&"</td><td>"&rs("name")&"</td><td>"&rs("date")&"</td>"
rs.moveNext
loop
我试了这样可以的呀,你也试一下吧
xiaozhaocnotc 2005-07-11
  • 打赏
  • 举报
回复
各位仁兄,可是我也是这么写的啊,但是没用,查不出来啊
lindy730 2005-07-11
  • 打赏
  • 举报
回复
前面加上datetime=date()
lindy730 2005-07-11
  • 打赏
  • 举报
回复
select * from table where sdtime like '%"&datetime&"%'
你用我这个包你行,快结帖给分
xiaozhaocnotc 2005-07-11
  • 打赏
  • 举报
回复
我只想搜索出这个表里当天的信息,你那种方法不是和我的一样嘛
wxiaol 2005-07-11
  • 打赏
  • 举报
回复
date()是当前系统日期

你要想搜索的目的是什么?

如果是搜索当日的信息
可以这样写
dates=Trim(date())
sql="select * from table where sdtime like '%"& dates &"%'"

28,406

社区成员

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

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