asp中查询最近一天\两天\一周\一个月等数据 sql用法
asp查access数据提交表单<selectname="qixian"class="textinput"><optionvalue=""selected>不限</opt...
asp查access数据
提交表单
<select name="qixian" class="textinput">
<option value="" selected>不限</option>
<option value="1" >近一天</option>
<option value="2" >近两天</option>
<option value="3" >近三天</option>
<option value="7" >近一周</option>
<option value="14" >近两周</option>
<option value="30" >近一月</option>
<option value="60" >近两月</option>
<option value="90" >近三月</option>
</select>
处理表单该怎么写啊?
试了很多函数都没通过
if request("qixian") <>"" then
select Case request("qixian")
Case 1
search=search & " and DateValue((date)>=DateValue('" & dateadd(d,-1,now())& "')" //date为access字段名
Case 2
search=search & " and datediff(d,data,now())<=2 "
Case 3
search=search & " and DateValue(date)>='" & date()-3 & "'"
Case 7
search=search & " and "
Case 14
search=search & " and date=#"&date()&"#"
Case 30
search=search & " and month(date)=" &month(date()) & " "
Case 60
search=search & " and date>='" & date()-60 & "'"
Case else
search=search & " and date>='" & date()-90 & "'"
end select
end if 展开
提交表单
<select name="qixian" class="textinput">
<option value="" selected>不限</option>
<option value="1" >近一天</option>
<option value="2" >近两天</option>
<option value="3" >近三天</option>
<option value="7" >近一周</option>
<option value="14" >近两周</option>
<option value="30" >近一月</option>
<option value="60" >近两月</option>
<option value="90" >近三月</option>
</select>
处理表单该怎么写啊?
试了很多函数都没通过
if request("qixian") <>"" then
select Case request("qixian")
Case 1
search=search & " and DateValue((date)>=DateValue('" & dateadd(d,-1,now())& "')" //date为access字段名
Case 2
search=search & " and datediff(d,data,now())<=2 "
Case 3
search=search & " and DateValue(date)>='" & date()-3 & "'"
Case 7
search=search & " and "
Case 14
search=search & " and date=#"&date()&"#"
Case 30
search=search & " and month(date)=" &month(date()) & " "
Case 60
search=search & " and date>='" & date()-60 & "'"
Case else
search=search & " and date>='" & date()-90 & "'"
end select
end if 展开
1个回答
展开全部
你写的不是很清晰 你看我写的 也不知道你能不能看懂
<%
qx=request("qixian") //得到表单里面的value
sdata=now()-qx //用现在的时间减去期限的时间就是你要查询的那天的时间
set rs=server.createobject("adodb.recordset")
sql="select * from 表名 where data='"&sdata&"'" //选择查询
rs.open sql,conn,1,1
%>
能用就给哥们加分吧!:)
<%
qx=request("qixian") //得到表单里面的value
sdata=now()-qx //用现在的时间减去期限的时间就是你要查询的那天的时间
set rs=server.createobject("adodb.recordset")
sql="select * from 表名 where data='"&sdata&"'" //选择查询
rs.open sql,conn,1,1
%>
能用就给哥们加分吧!:)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询