新聞中心
對于VB.NET中的函數(shù),在學習的過程中需要從各個方面去進行日常的經(jīng)驗積累,才能方便我們?nèi)蘸笫褂谩T谶@里就先為大家介紹兩種常用的VB.NET時間函數(shù),方便大家參考學習,增加自己對VB.NET編程的理解。#t#

VB.NET時間函數(shù)之函數(shù)Dateadd()
功能:計算某個指定的時間和
格式: dateadd(timeinterval,number,date)
參數(shù):timeinterval是時間單位(月,日..); number是時間間隔值,date是時間始點.
例子:
- < %
- currentDate = #8/4/99#
- newDate = DateAdd
(“m”,3,currentDate)- response.write newDate
- %>
- < %currentDate =
#12:34:45 PM#- newDate = DateAdd
(“h”,3,currentDate)- response.write newDate
- %>
結(jié)果:
11/4/99
3:34:45 PM
其中
“m” = ”month”;
“d” = ”day”;
如果是currentDate 格式,則,
“h” = ”hour”;
“s” = ”second”;
VB.NET時間函數(shù)之函數(shù)Datediff()
功能:計算某量個指定的時間差
格式: datediff(timeinterval,date1,date2[,firstdayofweek[,firstdayofyear]])
參數(shù): timeinterval 是時間單位; date1,date2是有效的日期表達式,firstdayofweek,firstdayofyear 是任意選項.
例子:
- < %fromDate = #8/4/99#
- toDate = #1/1/2000#
- response.write ”There
are ” & _- DateDiff(“d”,fromDate,
toDate) & _- “ days to millenium
from 8/4/99.”- %>
結(jié)果:There are 150 days to millenium from 8/4/99.
本文名稱:幾種常用VB.NET時間函數(shù)介紹
標題網(wǎng)址:http://fisionsoft.com.cn/article/cosodgo.html


咨詢
建站咨詢
