网络编程
位置:首页>> 网络编程>> Asp编程>> ASP函数大全(数字函数)(2)

ASP函数大全(数字函数)(2)

 来源:asp之家 发布时间:2009-06-01 12:33:00 

标签:函数,asp,时间,日期,数字



Date()

函数返回当前系统日期.

表达式 Date()

允许数据类型: None.

实例:

<%=Date%>
返回结果: 9/9/00


DateAdd()

函数返回一个被改变了的日期。

表达式 DateAdd(timeinterval,number,date)

允许数据类型:
timeinterval is the time interval to add;
number is amount of time intervals to add;
and date is the starting date.

实例:

<%

currentDate = #9/9/00#

newDate = DateAdd("m",3,currentDate)

response.write newDate

%>


<%

currentDate = #12:34:45 PM#

newDate = DateAdd("h",3,currentDate)

response.write newDate

%>

返回结果: 9/9/00

3:34:45 PM

"m" = "month";

"d" = "day";

If currentDate is in time format then,

"h" = "hour";

"s" = "second";


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 天.


Day()

函数返回一个月的第几日 .

表达式 Day(date)

允许数据类型: date 是任何有效的日期。

实例:

<%=Day(#9/9/00#)%>
返回结果: 4

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com