如何查询两个时间段内的记录?小妹初来贵宝地,望指教

ASP_sem 2007-07-11 12:07:20
我已经把年月日分开了
date1=trim(request("date1"))
date11=trim(request("date11"))
date2=trim(request("date2"))
date22=trim(request("date22"))
date3=trim(request("date3"))
date33=trim(request("date33"))
APPLY_TIME=date1&"-"&date2&"-"&date3
APPLY_TIME_end=date11&"-"&date22&"-"&date33

sql="select * from songzw.REQUIRE_BILL where 1=1"
if APPLY_TIME<>"" and APPLY_TIME_end<>"" then
sql=sql&"select * from songzw.REQUIRE_BILL where APPLY_TIME between '"& APPLY_TIME &"' and '"&APPLY_TIME_end&"' order by id desc"
end if
这样写可以吗?
if APPLY_TIME<>"" AND APPLY_TIME_END="" THEN
这下面要这么写??
...全文
136 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
littlelam 2007-07-11
  • 打赏
  • 举报
回复
sql="select * from songzw.REQUIRE_BILL where 1=1 "
if APPLY_TIME<>"" and APPLY_TIME_end<>"" then
sql=sql&" and APPLY_TIME between '"& APPLY_TIME &"' and '"&APPLY_TIME_end&"' order by id desc"
end if
littlelam 2007-07-11
  • 打赏
  • 举报
回复
sql="select * from songzw.REQUIRE_BILL where 1=1"
if APPLY_TIME<>"" and APPLY_TIME_end<>"" then
sql=sql&"and APPLY_TIME between '"& APPLY_TIME &"' and '"&APPLY_TIME_end&"' order by id desc"
end if
ASP_sem 2007-07-11
  • 打赏
  • 举报
回复
再请教下高手,怎样的模糊查询效率是最高的,能给段代码参考吗?
ASP_sem 2007-07-11
  • 打赏
  • 举报
回复
我这样写不知道可否,帮我看看
date1=trim(request("date1"))
date11=trim(request("date11"))
date2=trim(request("date2"))
date22=trim(request("date22"))
date3=trim(request("date3"))
date33=trim(request("date33"))
APPLY_TIME1=date1&"-"&date2&"-"&date3
APPLY_TIME_end1=date11&"-"&date22&"-"&date33
date1_wish=trim(request("date1_wish"))
date1_wish_end=trim(request("date1_wish_end"))
date2_wish=trim(request("date2_wish"))
date2_wish_end=trim(request("date2_wish_end"))
date3_wish=trim(request("date3_wish"))
date3_wish_end=trim(request("date3_wish_end"))
wish_finish1=date1_wish&"-"&date2_wish&"-"&date3_wish
wish_finish_end2=date1_wish_end&"-"&date2_wish_end&"-"&date3_wish_end

sql="select * from songzw.REQUIRE_BILL where 1=1"

if MAJOR_IDEA <>"" then
sql=sql&"and MAJOR_IDEA like '%"& MAJOR_IDEA &"%'"
end if

if APPLY_TIME1<>"" and APPLY_TIME_end1<>"" then
sql=sql&"select * from songzw.REQUIRE_BILL where APPLY_TIME between '"& APPLY_TIME1 &"' and '"& APPLY_TIME_end1&"' order by id desc"
'sql=sql&" and APPLY_TIME between '"& APPLY_TIME &"' and '"& APPLY_TIME_end &"' order by id desc"
end if

if APPLY_TIME1<>"" AND APPLY_TIME_END1="" THEN
sql=sql&" select * from songzw.REQUIRE_BILL where apply_time>='"& APPLY_TIME1 &"'order by id desc "
end if

if APPLY_TIME1="" AND APPLY_TIME_END1<>"" THEN
sql=sql&"select * from songzw.REQUIRE_BILL where apply_time<='" & apply_time_end1 &"' order by id desc"
end if
ASP_sem 2007-07-11
  • 打赏
  • 举报
回复
我主要是要知道下,如果
if APPLY_TIME<>"" AND APPLY_TIME_END="" THEN
sql=??????????????

这后面的应该要怎么写

28,391

社区成员

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

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