Lotusscript で 2 つの日付の差を計算したいと考えています。例: (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 月が 3 の場合、6 月の 6 に到達するには加算 (正) する必要があります。
于 2015-05-21T21:55:57.350 に答える
0
これは、日付を何に保存するかによって大きく異なります。日付のプログラミングは、Lotusscript の大きな問題です。
NotesDateTime オブジェクトを使用している場合は、Jasper のソリューションが最適ですが、何が何から差し引かれているのか混乱します。
簡単な方法は、日時アイテムの値を単数に変換して減算することです。小数点の前の部分は日、後の部分は時間など...
于 2015-01-13T15:53:21.753 に答える