1. 程式人生 > >VB計算兩個日期/時間之間的差(DateDiff函式)

VB計算兩個日期/時間之間的差(DateDiff函式)

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中不可用!