2011-10-18 25 views

回答

5

從Lotus Designer幫助:

爲TimeDifference方法,查找在一個日期時間和另一個之間秒的差異。

notesDateTime.TimeDifference(notesDateTime) 
+0

/86400天 –

+1

除非在執行.TimeDifference()之前在NotesDateTime對象上使用.SetAnyTime,否則當涉及到DST更改時,這可能會變得不可靠。 –

1
d1 = DateNumber(2011,10,18) 
d2 = DateNumber(2011,8,18) 

d1 = d1 - d2 
MessageBox d1 
0

這很大程度上取決於你要存儲什麼的。時間編程日期是在LotusScript中一個很大的痛苦。

如果您使用的是NotesDateTime對象,那麼Jasper的解決方案是最好的,儘管我對什麼被減少了什麼感到困惑。

一種簡單的方法是將日期時間項目值轉換爲單數,然後減去。小數點之前的部分是天,部分是小時後,等...

0

這裏是你可以把一個按鈕,看看它是如何工作的一個片段:

Sub Click(Source As Button) 
Dim workspace As New NotesUIWorkspace 
Dim uidoc As NotesUIDocument   
Dim doc As NotesDocument    
Dim startDT As New NotesDateTime("") 
Dim endDT As New NotesDateTime("") 
Dim diff As Long 

Set uidoc = workspace.CurrentDocument 
Set doc = uidoc.Document   

Set startDT = doc.getFirstItem("StartDate").dateTimeValue 
Call startDT.SetAnyTime 
Set endDT = doc.GetFirstItem("ReturnDate").dateTimeValue 
Call endDT.SetAnyTime 
diff = startDT.TimeDifference(endDT)  
Msgbox Cstr(diff) 
End Sub 

這裏有一個表我一直在幫我弄我周圍的數字大腦:

<table> 
    <tr> 
    <th>startDT</th> 
    <th>endDT</th> 
    <th>Result</th> 
    </tr> 
    <tr> 
    <td>June</td> 
    <td>March</td> 
    <td>Positive</td> 
    </tr> 
    <tr> 
    <td>June</td> 
    <td>October</td> 
    <td>Negative</td> 
    </tr> 
</table> 

如果三月是3,你必須添加(即模型正)來獲取到6月,這是6。如果在6月仍是6,從那裏十月,你必須減去(即負)。