|
蓝森林 http://www.lslnet.com 2006年8月25日 8:28
[asp/vbscript]日期格式的怪问题
比较=<%if FormatDateTime(now,2)=date() then
response.write"一致"
else
response.write"错误"
end if%>
最后显示的值是错误,为什么会不一样,是转换后的数据类型变了吗?
怎样写才能显示 "一致". |
试试这样
<%
if datediff("s",date(),FormatDateTime(now(),2))=0 then
response.write"一致"
else
response.write"错误"
end if
%>
|
感谢楼上的提供另一种思路,是一种可行的办法。
经过研究,也发现了自己的方式的问题。确实是数据类型不同引起的问题。
FormatDateTime(now,2)后的数据类型变成字符串了,唉。
正确的应该是
比较=<%if FormatDateTime(now,2)=CStr(date()) then
response.write"一致"
else
response.write"错误"
end if%>
当然也可以把前面的字符串类型转为日期类型,用函数CDate
|
哦
呵呵
是这样啊
学到了
感谢…… |
|