asp 调用文本域 进行查询问题

来源:百度知道 编辑:UC知道 时间:2024/09/21 14:29:37
文本域:
<input name="search_text" type="text">
查询语句:
select * from z_business_report_first where saledate=" & trim(request("search_text")) & "

saledate表的格式为 smalldatetime yy-mm-tt 00:00:00

前期测试使用:
select * from z_business_report_first where saledate='"&formatdatetime(now(),vbshortdate)&"'
能查到当天的数据,
现在需要通过文本域输入的时间来查询,
文本域的时间格式我想可以规范为"20080530"样式来规范,
就是写不来..请教
2008-05-31
如果规范成这样怎么写呢???
朋友谢谢!

将获得的字符型变量转成日期!但是日期只能规范成这样:2008-05-31
如果非要用20080530这样,可以通过字符串分割来获得,比喻:
response.Write(left("20080506",4)&"-"&mid("20080506",5,2)&"-"&mid("20080506",7,2))

CDate(trim(request("search_text")) )

你最好在输入文本框加一个日期控件或做成下拉菜单,然后再获取信息进行处理