日期:2014-05-17  浏览次数:20917 次

如何查询两个时间段内的记录?小妹初来贵宝地,望指教
我已经把年月日分开了
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
这下面要这么写??

------解决方案--------------------
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
------解决方案--------------------
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