我想计算 Lotusscript 中的两个日期差异。例如(2011 年 10 月 18 日 - 2011 年 8 月 18 日)= 71 天
问问题
6049 次
4 回答
5
从 Lotus Designer 帮助:
TimeDifference 方法,查找一个日期时间和另一个日期时间之间的秒差。
notesDateTime.TimeDifference( notesDateTime )
于 2011-10-18T07:11:32.100 回答
1
d1 = DateNumber(2011,10,18)
d2 = DateNumber(2011,8,18)
d1 = d1 - d2
MessageBox d1
于 2011-10-18T07:13:02.893 回答
1
这是一个片段,您可以将其放入按钮中以查看其工作原理:
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,要从十月到达那里,则必须减去(即负数)。
于 2015-05-21T21:55:57.350 回答
0
这在很大程度上取决于您将日期存储在什么中。日期编程是 Lotusscript 中的一大难题。
如果您使用的是 NotesDateTime 对象,那么 Jasper 的解决方案是最好的,尽管我对从什么中减去什么感到困惑。
一种简单的方法是将日期时间项目值转换为单数,然后减去。小数点前的部分是天,小数点后的部分是小时等...
于 2015-01-13T15:53:21.753 回答