在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