+ -
当前位置:首页 → 问答吧 → asp+access 查询时间段

asp+access 查询时间段

时间:2011-12-14

来源:互联网

conn.asp
<%
startdate = Trim(request("startdate"))
enddate = Trim(request("enddate"))

set rs = server.CreateObject("adodb.recordset")
sql = "select * from biao order by id asc"
if startdate<>"" then 
sql = sql&" and time>= '"&startdate&"'"
end if
if enddate<>"" then 
sql = sql&" and time<= '"&enddate&"'" 
end if

sql = sql&" order by id desc" 
rs.open sql,conn,1,1
%>

1.asp
<form id="form" name="form" method="post" action="time">
  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
   
  <tr>
  <td width="709" height="25" align="left" valign="middle">起始日期:
<input name="startdate" type="text" id="startdate" size="15" value="<%=startdate%>"/>
  截止日期:
<input name="enddate" type="text" id="enddate" size="15" value="<%=enddate%>"/></td>
  <td width="91"><input type="submit" name="button" id="button" value="查询" /></td>
  </tr>
  </table>
  </form> 
下面就是所要输出的内容,应该怎么写呢

作者: error911   发布时间: 2011-12-14

select * from ta where datediff('d','" & startdate& "',数据库字段)>=0 and datediff('d','" &enddate&"',数据库字段)<=0

作者: sy_binbin   发布时间: 2011-12-14