求助 关于用时间作为参数的搜索

dawn06 2003-07-01 02:03:00
access中有一数据类型now() 存放的数据如2003-7-1 1:01:26

现在传进一参数如 2003-7-1 用此参数搜索出当天所有的纪录 该怎么写

sql语句
...全文
59 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
dawn06 2003-07-01
  • 打赏
  • 举报
回复
datediff('d', msgdate,'2003-7-1')=0

ok
dawn06 2003-07-01
  • 打赏
  • 举报
回复
这样写为什么还错

<!--#INCLUDE FILE="inc\conn.asp" -->
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body>
<% Set rsDept=Server.CreateObject("ADODB.Recordset")
sql="select * from msg where datediff(day, msgdate,'2003-7-1')=0"
rsDept.Open sql,connstr,3,1
while not rsdept.eof
response.Write rsdept("msgdate")
response.Write "<BR>"
rsdept.movenext
wend
rsdept.close
%>

</body>
</html>
alianasia 2003-07-01
  • 打赏
  • 举报
回复
select * from tblname where datediff(day,字段名,'2003-7-1')=0
wsmall 2003-07-01
  • 打赏
  • 举报
回复
直接写没有问题的。
sj = cstr(now())

sql = "select * from table where 字段名称='"&sj&"'"

我记得这样事可以的,你试一下

要不改成like

sql = "select * from table where 字段名称 like'"&sj&"'"
gq 2003-07-01
  • 打赏
  • 举报
回复
select * from tblname where datediff(day,now,'2003-7-1')=0
dawn06 2003-07-01
  • 打赏
  • 举报
回复
2003-7-1 是字符串

28,391

社区成员

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

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