使用TimeDifference,實現兩個時間變量的相減,得出秒間隔

在Lotusscript中如何實現兩個時間變量相減,我們可以使用TimeDifference函數:

首先兩個時間變量的格式必須相同:

Dim strDate As NotesDateTime

Dim endDate As NotesDateTime


Set strDate = New NotesDateTime(Format("01/09/2011","dd/mm/yyyy"))

Set endDate = New NotesDateTime(Format("01/09/2011","dd/mm/yyyy"))


然後通過imeDifference方法,取得兩個時間秒差值:

datediff = endDate.TimeDifference(strDate)/60/60/24

'輸出查看天數

Msgbox datediff


源代碼:

Sub Initialize

On Error Goto errhandle


Dim strDate As NotesDateTime

Dim endDate As NotesDateTime


Set strDate = New NotesDateTime(Format("01/09/2011","dd/mm/yyyy"))

Set endDate = New NotesDateTime(Format("20/09/2011","dd/mm/yyyy"))


datediff = endDate.TimeDifference(strDate)/60/60/24

Msgbox datediff


Exit Sub

errhandle:

Msgbox "兩個時間變量相減:" & Erl & Error$

Exit Sub

End Sub

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章