[学习日记]vb.net里的两个重要的时间函数

从别人那里看来的,为了方便,放在自己这里,经常会用到的

函数Dateadd() 
 功能:计算某个指定的时间和 
 格式: dateadd(timeinterval,number,date) 
 参数: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 
 %> 
 结果: 
 11/4/99 
 3:34:45 PM 
 其中 
 “m” = ”month”; 
 “d” = ”day”; 
 如果是currentDate 格式,则, 
 “h” = ”hour”; 
 “s” = ”second”;
  
  函数Datediff() 
 功能:计算某量个指定的时间差 
 格式: datediff(timeinterval,date1,date2[,firstdayofweek[,firstdayofyear]]) 
 参数: 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.” 
 %> 
 结果:There are 150 days to millenium from 8/4/99. 

转载于:https://www.cnblogs.com/aowind/archive/2005/03/03/111858.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值