首先,用下面函数把日期转换长2004-06-01格式<%Rem 改变日期为长进制 function datetod(str) if isnull(str) then checkStr = "" exit function end if dateyear =year(str) datemonth =month(str) dateday =day(str) if len(datemonth)=1 then datemonth="0"&datemonth end if if len(dateday)=1 then dateday="0"&dateday end if datetod=dateyear&"-"&datemonth&"-"&dateday end function %> 其次:select * from jqhkbz where startdate<='"& Datetod(datekey)&"' and enddate>'"& Datetod(datekey)&"'
分别取到二个时间的值记为如$date1,$date2,然后写查询语句 如$sql = "select * from case where case_date>='$date1' and case_date<='$date2'";
function datetod(str)
if isnull(str) then
checkStr = ""
exit function
end if
dateyear =year(str)
datemonth =month(str)
dateday =day(str)
if len(datemonth)=1 then
datemonth="0"&datemonth
end if
if len(dateday)=1 then
dateday="0"&dateday
end if
datetod=dateyear&"-"&datemonth&"-"&dateday
end function
%>
其次:select * from jqhkbz where startdate<='"& Datetod(datekey)&"' and enddate>'"& Datetod(datekey)&"'
如$sql = "select * from case where case_date>='$date1' and case_date<='$date2'";
用别的方法都太麻烦....
http://community.csdn.net/Expert/topic/3025/3025781.xml?temp=8.205813E-02