广州购买羊城通:用ASP+SQL作的网页,怎么判断数据库中的时间
来源:百度文库 编辑:杭州交通信息网 时间:2024/04/29 04:55:44
二楼的。date()和a1 好像不能计算吧。 date()取出了日期,A1只是取出了月份。
'<%
'Set rs9=Server.CreateObject("ADODB.Recordset")
'sql9="select youxiaoriqi,qianzhengyouxiaoqi from huzhao where youxiaoriqi=date()+month(now())"
'rs9.open sql9,conn,3,2
'if not rs9.eof then
'do while (not rs.eof)
'%>
'<%
'rs.movenext
' loop
' end if
''%>
这个该怎么写
"select youxiaoriqi,qianzhengyouxiaoqi from huzhao"
if not rs9.eof then
do while (not rs.eof)
if date()-rs.fields("youxiaoriqi")<30 then
response.write "还有" &date()-rs.fields("youxiaoriqi") & "天"
end if
rs.movenext
loop
end if
'sql9="select youxiaoriqi,qianzhengyouxiaoqi from huzhao where youxiaoriqi<(getdate()+30)"
希望到现在还能有帮助
DateDiff("n", Now, 读出数据库中的时间)
DateDiff(interval, date1, date2 [,firstdayofweek[, firstweekofyear]])
具体语法你可以百度
Date1=Date()-30
Sql="select * from huzhao where datediff(dd,'"&cdate(Date1)&"',convert(char(10),护照有效期字段,21))=0"
表 huzhao
列 a1(护照有效期) a2(签证有效期)
a1和a2不知道你是怎么定义的
我的思路如下:
sql执行的是select * from huzhao
……
a1=rs(month(a1))
a2=rs(month(a2))
if DateDiff("d",date(),a1)<=30 then
response.write("护照还差"&DateDiff("d",date(),a1)&"天到期")
end if
if DateDiff("d",date(),a2)<=30 then
response.write("签证还差"&DateDiff("d",date(),a1)&"天到期")
end if
只是思路。有好方法的朋友贴出来。
if datediff("d",数据表里的字段,now())<30 then.......
now()是获得当前时间的函数。“d”表示是的以天算。
要是用select语句的话可以
select datediff('d','1991-6-12','1992-6-21')<30