Lotus notes 我想计算Lotusscript(IBMLotusNotes8.5)中的两个日期差

Lotus notes 我想计算Lotusscript(IBMLotusNotes8.5)中的两个日期差,lotus-notes,lotus-domino,lotusscript,Lotus Notes,Lotus Domino,Lotusscript,我想计算Lotusscript中的两个日期差。 e、 g.(2011年10月18日-2011年8月18日)=71天来自Lotus Designer帮助: TimeDifference方法,查找一个日期时间和另一个日期时间之间的差异(以秒为单位) notesDateTime.TimeDifference( notesDateTime ) 这在很大程度上取决于您将日期存储在什么中。日期编程是Lotusscript的一大难题 如果您使用的是NotesDateTime对象,那么Jasper的解决方案是

我想计算Lotusscript中的两个日期差。
e、 g.(2011年10月18日-2011年8月18日)=71天来自Lotus Designer帮助:

TimeDifference方法,查找一个日期时间和另一个日期时间之间的差异(以秒为单位)

notesDateTime.TimeDifference( notesDateTime )

这在很大程度上取决于您将日期存储在什么中。日期编程是Lotusscript的一大难题

如果您使用的是NotesDateTime对象,那么Jasper的解决方案是最好的,尽管我对从什么中减去什么感到困惑


一种简单的方法就是将日期时间项值转换为单数,然后进行减法运算。小数点前的部分是天,小数点后的部分是小时等。

这里有一个片段,你可以放在按钮中查看它是如何工作的:

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>

startDT
恩德特
结果
六月
前进
肯定的
六月
十月
消极的

如果3月是3日,则必须添加(即正值)才能到达6月,即6日。如果6月还是6日,要从10月开始计算,必须进行减法运算(即负数)。

Lotus script是BASIC的一个变体,因此javascript标记不合适。如果涉及DST更改,则可能会出现问题,除非在执行.TimeDifference()之前在NotesDateTime对象上使用.SetAnyTime。
<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>