VB计算两个日期/时间之间的差(DateDiff函数)

来源:互联网 发布:淘宝网棉服韩版 编辑:程序博客网 时间:2024/05/16 13:46

DateDiff()

 

  函数返回两个日期之间的差值 。

  表达式 DateDiff(timeinterval,date1,date2 [, firstdayofweek [, firstweekofyear]])

  允许数据类型: timeinterval 表示相隔时间的类型,代码为:

  “y“表示“年”

  “m“表示“月”

  “d“表示“日”

  “h“表示“时”

  “n“表示“分”

  “s“表示“秒”。

  实例: <%

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

  该函数在mssql中可用,在oracle中不可用!

原创粉丝点击