【发布时间】:2015-05-22 05:55:57
【问题描述】:
我想在 Lotusscript 中计算两个日期的差异。 例如(10/18/2011 - 08/18/2011) = 71 天
【问题讨论】:
-
莲花脚本是BASIC的变种,所以javascript标签不合适。
标签: lotus-notes lotus-domino lotusscript
我想在 Lotusscript 中计算两个日期的差异。 例如(10/18/2011 - 08/18/2011) = 71 天
【问题讨论】:
标签: lotus-notes lotus-domino lotusscript
来自 Lotus Designer 帮助:
TimeDifference 方法,查找一个日期时间和另一个日期时间之间的秒差。
notesDateTime.TimeDifference( notesDateTime )
【讨论】:
d1 = DateNumber(2011,10,18)
d2 = DateNumber(2011,8,18)
d1 = d1 - d2
MessageBox d1
【讨论】:
这是一个sn-p,你可以在按钮中查看它是如何工作的:
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,要从十月到达那里,您必须减去(即负数)。
【讨论】:
这在很大程度上取决于您将日期存储在什么中。日期编程是 Lotusscript 中的一大难题。
如果您使用的是 NotesDateTime 对象,那么 Jasper 的解决方案是最好的,尽管我对从什么中减去什么感到困惑。
一种简单的方法是将日期时间项目值转换为单数,然后减去。小数点前为天,小数点后为小时等...
【讨论】: