几种常用VB.NET时间函数介绍

开发 后端
使用VB.NET进行实际编程时,会发现其中每一个函数都有自己特定的功能。比如我们这里为大家介绍的VB.NET时间函数就是其中一个功能强大的函数。

对于VB.NET中的函数,在学习的过程中需要从各个方面去进行日常的经验积累,才能方便我们日后使用。在这里就先为大家介绍两种常用的VB.NET时间函数,方便大家参考学习,增加自己对VB.NET编程的理解。#t#

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     %>   
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.

结果: 
11/4/99 
3:34:45 PM 
其中 
“m” = ”month”; 
“d” = ”day”; 
如果是currentDate 格式,则, 
“h” = ”hour”; 
“s” = ”second”;
 
VB.NET时间函数之函数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.”    
%>   
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.

结果:There are 150 days to millenium from 8/4/99. 

责任编辑:曹凯 来源: 博客园
相关推荐

2010-01-12 09:37:48

VB.NET调用IE

2009-10-28 09:55:29

VB.NET MyCl

2009-11-10 12:06:17

VB.NET字符串函数

2009-10-15 17:50:48

VB.NET Spli

2009-11-10 10:28:20

VB.NET诞生

2009-10-12 15:02:51

VB.NET动态控件

2010-01-07 15:25:11

VB.NET数组

2010-01-21 16:45:00

VB.NET继承规则

2009-10-21 10:45:50

VB.NET Quic

2010-01-07 16:08:45

VB.NET子过程和函

2010-01-22 10:41:33

VB.NET声明结构

2009-10-12 13:19:14

VB.NET线程同步

2009-11-10 12:42:47

VB.NET Prin

2010-01-18 11:20:13

VB.NET默认属性

2010-01-15 18:12:28

VB.NET超链接

2010-01-08 18:31:45

VB.NET历史菜单

2009-08-18 16:57:24

VB.NET和C#

2010-01-07 16:40:13

VB.NET一维数组

2009-11-02 10:36:16

VB.NET Sub

2010-01-21 17:58:40

VB.NET List
点赞
收藏

51CTO技术栈公众号