【问题标题】:I want to calculate 2 dates difference in Lotusscript (IBM Lotus Notes 8.5)我想计算 Lotusscript 中的 2 个日期差异(IBM Lotus Notes 8.5)
【发布时间】:2015-05-22 05:55:57
【问题描述】:

我想在 Lotusscript 中计算两个日期的差异。 例如(10/18/2011 - 08/18/2011) = 71 天

【问题讨论】:

  • 莲花脚本是BASIC的变种,所以javascript标签不合适。

标签: lotus-notes lotus-domino lotusscript


【解决方案1】:

来自 Lotus Designer 帮助:

TimeDifference 方法,查找一个日期时间和另一个日期时间之间的秒差。

notesDateTime.TimeDifference( notesDateTime )

【讨论】:

  • 这可能会在涉及 DST 更改时出现问题,除非您在执行 .TimeDifference() 之前在 NotesDateTime 对象上使用 .SetAnyTime。
【解决方案2】:
d1 = DateNumber(2011,10,18)
d2 = DateNumber(2011,8,18)

d1 = d1 - d2
MessageBox d1

【讨论】:

    【解决方案3】:

    这是一个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,要从十月到达那里,您必须减去(即负数)。

    【讨论】:

      【解决方案4】:

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

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

      一种简单的方法是将日期时间项目值转换为单数,然后减去。小数点前为天,小数点后为小时等...

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-11-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多