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

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

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

VB.NET时间函数之函数Dateadd() 

功能:计算某个指定的时间和 

格式: dateadd(timeinterval,number,date) 

参数:timeinterval是时间单位(月,日..); number是时间间隔值,date是时间始点. 

例子: 

  1. < %    
  2. currentDate = #8/4/99#    
  3. newDate = DateAdd
    (“m”,3,currentDate)    
  4. response.write newDate    
  5. %>   
  6. < %currentDate = 
    #12:34:45 PM#    
  7. newDate = DateAdd
    (“h”,3,currentDate)    
  8. response.write newDate    
  9. %>   

结果: 
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 是任意选项. 

例子: 

  1. < %fromDate = #8/4/99#    
  2. toDate = #1/1/2000#    
  3. response.write ”There 
    are ” & _    
  4. DateDiff(“d”,fromDate,
    toDate) & _    
  5. “ days to millenium 
    from 8/4/99.”    
  6. %>   

结果: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-10-21 10:45:50

VB.NET Quic

2009-10-12 15:02:51

VB.NET动态控件

2009-11-10 10:28:20

VB.NET诞生

2010-01-21 16:45:00

VB.NET继承规则

2010-01-07 15:25:11

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-07 16:08:45

VB.NET子过程和函

2009-10-26 10:44:27

VB.NET API函

2010-01-18 10:33:28

VB.NET基本函数

2009-10-28 15:01:59

VB.NET SHEL

2009-11-02 13:14:18

VB.NET函数

2010-01-08 18:31:45

VB.NET历史菜单

2010-01-18 11:20:13

VB.NET默认属性

2009-08-18 16:57:24

VB.NET和C#
点赞
收藏

51CTO技术栈公众号