hcl-bot
1
Hi,
please help me in my lotusscript. i wanted to calculate two dates in days. below is my script in QuerySave:
If source.Document.HasItem(“DueDate”) And source.Document.HasItem(“DateComposed”) Then
Set varDueDate = source.Document.GetFirstItem(“DueDate”)
Set varDatecomposed = source.Document.GetFirstItem(“DateComposed”)
continue = False
End If
varValue = varDueDate.value(0)
varValue2 = varDatecomposed.value(0)
varValue3 = Cstr(Cint(varValue - varValue2))
thanks
hcl-bot
2
Subject: Difference between two dates in Days
Don’t think you will get your expected results following this approach.
Don’t understand the continue = false without and exit sub.
More to the point.
Something closer might be:
set dueDateTime = New NotesDateTime(varDueDate.values(0))
set dueDateComposedTime = New NotesDateTime(varDateComposed.values(0))
numSeconds = dueDateTime.TimeDifference(dueDateComposedTime)/86400
Haven’t tested that, but give it a try, it should be close.
Jason
hcl-bot
3
Subject: RE: Difference between two dates in Days
well…it won’t work still. i have this error, ‘Variants does not contain an odject’
please see below script(edited):
Sub Querysave(Source As Notesuidocument, Continue As Variant)
If source.Document.HasItem(“DueDate”) And source.Document.HasItem(“DateComposed”) Then
Set dueDateTime = New NotesDateTime(varDueDate.values(0))
Set dueDateComposedTime = New NotesDateTime(varDateComposed.values(0))
numSeconds = dueDateTime.TimeDifference(dueDateComposedTime)/86400
End If
If source.Document.HasItem ( “Reason” ) And numSeconds => 3 Then
Set varBody = source.Document.GetFirstItem ( “Reason” )
If source.Document.HasItem ( “$Links” ) Then
Set varLinks = source.Document.GetFirstItem ( “$Links” )
End If
Else
Messagebox “Please attach a incident report”
continue = False
End If
End Sub
the script prompts a message when numseconds is less than 3 and no doclink found in the document.
please help. m new to designer.
hcl-bot
4
Subject: RE: Difference between two dates in Days
sorry for clumsiness…have this error, ‘Type mismatch’ in the script below (edited again):
Sub Querysave(Source As Notesuidocument, Continue As Variant)
If source.Document.HasItem(“DueDate”) And source.Document.HasItem(“DateComposed”) Then
Set varDueDate = source.Document.GetItemValue(“DueDate”)
Set varDatecomposed = source.Document.GetItemValue(“DateComposed”)
Set dueDateTime = New NotesDateTime(varDueDate.values(0))
Set dueDateComposedTime = New NotesDateTime(varDateComposed.values(0))
numSeconds = dueDateTime.TimeDifference(dueDateComposedTime)/86400
If source.Document.HasItem ( “Reason” ) And numSeconds => 3 Then
Set varBody = source.Document.GetFirstItem ( “Reason” )
If source.Document.HasItem ( “$Links” ) Then
Set varLinks = source.Document.GetFirstItem ( “$Links” )
End If
Else
Messagebox "Please attach a incident report"
Continue = False
Exit Sub
End If
End If
End Sub
hcl-bot
5
Subject: RE: Difference between two dates in Days
Sub Querysave(Source As Notesuidocument, Continue As Variant)
If source.Document.HasItem(“DueDate”) And source.Document.HasItem(“DateComposed”) Then
'Removed SET
varDueDate = source.Document.GetItemValue(“DueDate”)
'Removed SET
varDatecomposed = source.Document.GetItemValue(“DateComposed”)
Set dueDateTime = New NotesDateTime(varDueDate.values(0))
Set dueDateComposedTime = New NotesDateTime(varDateComposed.values(0))
numSeconds = dueDateTime.TimeDifference(dueDateComposedTime)/86400
'Changed => to >=
If source.Document.HasItem ( “Reason” ) And numSeconds >= 3 Then
Set varBody = source.Document.GetFirstItem ( “Reason” )
If source.Document.HasItem ( “$Links” ) Then
Set varLinks = source.Document.GetFirstItem ( “$Links” )
End If
Else
Messagebox “Please attach a incident report”
Continue = False
Exit Sub
End If
End If
End Sub
If this has a problem, then tell/show me the line throwing the problem using Erl, Err and Error.
Thanks,
Jason
hcl-bot
6
Subject: RE: Difference between two dates in Days
thanks Jason…
i tried this but error message, “Variant does not contain an object” appeared when i saved the document.
hmm…how do i know which line has a problem here…tsk. sorry im new to designer.
hcl-bot
7
Subject: Difference between two dates in Days
Don’t forget to divide by 86,400 (seconds in a day).