惠州哪里泡温泉最好:asp小问题

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 05:51:34
我想计算出从今天到2006年7月29日的天数用以下函数应该没有问题
可是我这样写为什么没有计算出来呢?
<%
dim a
a=date()-cdate("2006-7-29")
reponse.write a
%>
为什么计算不出来呢??

用一个函数即可:
DateDiff()

函数返回两个日期之间的差值 。

表达式 DateDiff(timeinterval,date1,date2 [, firstdayofweek [, firstweekofyear]])

允许数据类型: timeinterval 表示相隔时间的类型,如“M“表示“月”。

实例: <%

fromDate = #9/9/00#

toDate = #1/1/2000#

response.write "There are " & _

DateDiff("d",fromDate,toDate) & _

" days to millenium from 9/9/00."

%>

返回结果: 从9/9/00 到2000年还有 150 天.

<%
dim a
a=DateDiff("d", date(), "2006-7-29")
reponse.write a
%>
这样写

<%
dim a
a=DateDiff("d", Now, #2006-7-29#)
reponse.write a
%>
这样写