datefiff-时间判断函数的问题
有一个公告栏,显示上传公告。判断,如果上传时间在10天之内,则显示该公告,设定最多显示三个公告。否则显示“暂时没有公告”,现在出的问题是,一直显示“暂时没有公告”,难道是时间函数判断错误?请大家指正,下面是代码。
<%
set rs=Server.CreateObject( "ADODB.recordset ")
sql= "select * from uploadlist where receive= '公告栏 ' and datediff( 'd ',difftime),now) <10 order by id desc "
rs.Open sql,conn,1,1
if rs.eof and rs.bof then
%>
<MARQUEE height= "110 " width= "176 " direction=up onmouseout= "this.start(); " onmouseover= "this.stop(); " scrollAmount=1 scrollDelay=20 scrollleft= "0 " scrolltop= "0 ">
<font color= "#ff0000 "> <strong> 最新公告: </strong> </font> <br>
<font color= "#ff0000 "> 暂时没有公告 </strong> </font>
</marquee>
<%else%>
<MARQUEE height= "110 " width= "176 " direction=up onmouseout= "this.start(); " onmouseover= "this.stop(); " scrollAmount=1 scrollDelay=20 scrollleft= "0 " scrolltop= "0 ">
<%
k=1
for k=1 to 3
response.write(rs( "gonggao "))
k=k+1
rs.movenext
next
%>
</marquee>
<%end if%>
------解决方案--------------------datediff第一个参数在SQL中最好用常数DAY,
你difftime)的括号做什么用的,怎么看都是写错了的
如果是MSSQL 请把NOW换成GETDATE() ,
试试datediff(day,difftime,now) 或datediff(day,difftime,getdate())
------解决方案-------------------- 'd ' datadiff函数在程序中,要把参数引起来,在sql语句中,不要用引号. 改成d,即可.