Discussion:
Date/Time comparison in LotusScript
b***@averittexpress.com
2004-10-08 20:28:52 UTC
Permalink
Since this seems to be LotusScript day.

I'm working on a project and I need to do a Do While loop until a
particular date/time equals a second date time. How do I set up a
comparison that in formula would be :

@If(BeginTime = EndingTime;Stop;Keep Going)

Every time I try a comparison in LS, I'm getting a type mismatch: and
that's saving not running the script. I can't make claims to being a
scripter, and time makes it worse.

Brian
J***@crown.com
2004-10-08 20:57:51 UTC
Permalink
Brian,

Here is an agent that I had set up to send notification to people if the
document was not assigned to a user. This agent runs through a specified
view and processes all unprocessed documents. I had a due date on the
form. Hope this helps. I know date and time can be a tough one.

Thanks,
Jean

Sub Initialize
Dim s As New NotesSession
Dim db As notesdatabase
Dim maildoc As notesdocument
Dim view As notesview
Dim ndc As notesdocumentcollection
Dim CurrentRequest As NotesDocument
Set db = s.currentdatabase

Set ndc= db.UnprocessedDocuments
'Set ndc = db.alldocuments

Dim body As notesrichtextitem
Dim currentDT As New NotesDateTime("")


Set view=db.getview("OrdersNotAssigned")
Call currentDT.SetNow
Dim assigned_time As New NotesDateTime("")
'Set assigned_time = doc.getFirstItem("Ord_date_reqd").dateTimeValue
Dim diff As Long
Dim order_date As String
Dim order_number As String
Dim ord_required As String

For x = 1 To ndc.count

Set CurrentRequest = ndc.getnthdocument(x)
If CurrentRequest.form(0)="Order" Then
If CurrentRequest.assigned_to(0) = "" Then
If CurrentRequest.HasItem( "due_date_1" ) Then
Set assigned_time =
currentrequest.getFirstItem("due_date_1").dateTimeValue
diff =
currentDT.TimeDifference(assigned_time)

If diff > 86400 Then
'If diff > 10 Then
'Sends notice to Jean Stachler

order_date = currentrequest.ord_date(0)
order_number =
currentrequest.ord_number(0)
ord_required =
currentrequest.ord_date_reqd(0)
Set maildoc=New notesdocument(db)
Set body = New NotesRichTextItem(
maildoc, "Body" )
maildoc.sendto=
"***@crown.com"
maildoc.form="Memo"
maildoc.Principal = CurrentRequest.Name
maildoc.subject = "Office Supply
Requests Not Assigned within the last 24 hours."
Call body.appendtext("The attached doc
link has not been assigned to anyone in the Fulfillment Services
Group at this time,")
Call body.appendtext("if you open the
doclink, your name will be assigned to the document.")
Call body.addnewline(2)
Call body.appendtext("The Order date is
" + order_date + ", and the order number is "+ order_number +".")
Call body.appendtext("The required due
date for the order is " + ord_required + ".")
Call body.addnewline(2)
Call body.AppendDocLink(
currentrequest, "" )
Call maildoc.send(True)
Else
End If
Else

End If
Else
End If
Else
End If


Next

End Sub



***@averittexp
ress.com To: Multiple recipients of list LNOTES-L <lnotes-***@ozzie.notesnic.net>
Sent by: cc:
lnotes-***@ozzie.no Subject: Date/Time comparison in LotusScript
tesnic.net


10/08/2004 04:28
PM
Please respond to
lnotes-l






Since this seems to be LotusScript day.

I'm working on a project and I need to do a Do While loop until a
particular date/time equals a second date time. How do I set up a
comparison that in formula would be :

@If(BeginTime = EndingTime;Stop;Keep Going)

Every time I try a comparison in LS, I'm getting a type mismatch: and
that's saving not running the script. I can't make claims to being a
scripter, and time makes it worse.

Brian
J***@crown.com
2004-10-08 21:02:48 UTC
Permalink
Brian,

One other thing I should have mentioned, the comparison made below "86400"
is the number of seconds in a 24 hour day. Adjust the time to whatever you
want to compare to or calculate the time and enter that value in seconds.
Thanks,
Jean



***@cro
wn.com To: Multiple recipients of list LNOTES-L <lnotes-***@ozzie.notesnic.net>
Sent by: cc:
lnotes-***@ozzie.no Subject: Re: Date/Time comparison in LotusScript
tesnic.net


10/08/2004 04:57
PM
Please respond to
lnotes-l







Brian,

Here is an agent that I had set up to send notification to people if the
document was not assigned to a user. This agent runs through a specified
view and processes all unprocessed documents. I had a due date on the
form. Hope this helps. I know date and time can be a tough one.

Thanks,
Jean

Sub Initialize
Dim s As New NotesSession
Dim db As notesdatabase
Dim maildoc As notesdocument
Dim view As notesview
Dim ndc As notesdocumentcollection
Dim CurrentRequest As NotesDocument
Set db = s.currentdatabase

Set ndc= db.UnprocessedDocuments
'Set ndc = db.alldocuments

Dim body As notesrichtextitem
Dim currentDT As New NotesDateTime("")


Set view=db.getview("OrdersNotAssigned")
Call currentDT.SetNow
Dim assigned_time As New NotesDateTime("")
'Set assigned_time = doc.getFirstItem("Ord_date_reqd").dateTimeValue
Dim diff As Long
Dim order_date As String
Dim order_number As String
Dim ord_required As String

For x = 1 To ndc.count

Set CurrentRequest = ndc.getnthdocument(x)
If CurrentRequest.form(0)="Order" Then
If CurrentRequest.assigned_to(0) = "" Then
If CurrentRequest.HasItem( "due_date_1" ) Then
Set assigned_time =
currentrequest.getFirstItem("due_date_1").dateTimeValue
diff =
currentDT.TimeDifference(assigned_time)

If diff > 86400 Then
'If diff > 10 Then
'Sends notice to Jean Stachler

order_date = currentrequest.ord_date(0)
order_number =
currentrequest.ord_number(0)
ord_required =
currentrequest.ord_date_reqd(0)
Set maildoc=New notesdocument(db)
Set body = New NotesRichTextItem(
maildoc, "Body" )
maildoc.sendto=
"***@crown.com"
maildoc.form="Memo"
maildoc.Principal = CurrentRequest.Name
maildoc.subject = "Office Supply
Requests Not Assigned within the last 24 hours."
Call body.appendtext("The attached doc
link has not been assigned to anyone in the Fulfillment Services
Group at this time,")
Call body.appendtext("if you open the
doclink, your name will be assigned to the document.")
Call body.addnewline(2)
Call body.appendtext("The Order date is
" + order_date + ", and the order number is "+ order_number +".")
Call body.appendtext("The required due
date for the order is " + ord_required + ".")
Call body.addnewline(2)
Call body.AppendDocLink(
currentrequest, "" )
Call maildoc.send(True)
Else
End If
Else

End If
Else
End If
Else
End If


Next

End Sub



***@averittexp

ress.com To: Multiple
recipients of list LNOTES-L <lnotes-***@ozzie.notesnic.net>
Sent by: cc:

lnotes-***@ozzie.no Subject: Date/Time
comparison in LotusScript
tesnic.net



10/08/2004 04:28

PM

Please respond to

lnotes-l







Since this seems to be LotusScript day.

I'm working on a project and I need to do a Do While loop until a
particular date/time equals a second date time. How do I set up a
comparison that in formula would be :

@If(BeginTime = EndingTime;Stop;Keep Going)

Every time I try a comparison in LS, I'm getting a type mismatch: and
that's saving not running the script. I can't make claims to being a
scripter, and time makes it worse.

Brian
b***@averittexpress.com
2004-10-08 21:30:54 UTC
Permalink
Jean,

Thank you very much. I've not had a chance to look at this yet, but I
really, really appreciate it.

Brian
d***@koretsf.com
2004-10-11 05:04:51 UTC
Permalink
This is a multipart message in MIME format.
--=_alternative 001AD2C188256F2A_=
Content-Type: text/plain; charset="US-ASCII"

Straight from the Help files....you're going to need to declare the items
as NotesDateTime items to do the comparison. The simplest way is to
extract them from an already declared NotesItem.

Dim item As NotesItem
Dim dateTime As NotesDateTime
Set item = doc.GetFirstItem( "DateComposed" )
Set dateTime = item.DateTimeValue


Hope this helps,
Don

<><><><><><><><><><><>
Don Shennum
Technical Business Analyst
Koret of California, Inc.
505 14th Street
Oakland, CA 94612
(510) 622-7383
***@koretsf.com
http://www.koretsf.com
<><><><><><><><><><><>





***@averittexpress.com
Sent by: lnotes-***@ozzie.notesnic.net
10/08/2004 01:28 PM
Please respond to
lnotes-***@ozzie.notesnic.net


To
Multiple recipients of list LNOTES-L <lnotes-***@ozzie.notesnic.net>
cc

Subject
Date/Time comparison in LotusScript






Since this seems to be LotusScript day.

I'm working on a project and I need to do a Do While loop until a
particular date/time equals a second date time. How do I set up a
comparison that in formula would be :

@If(BeginTime = EndingTime;Stop;Keep Going)

Every time I try a comparison in LS, I'm getting a type mismatch: and
that's saving not running the script. I can't make claims to being a
scripter, and time makes it worse.

Brian


--=_alternative 001AD2C188256F2A_=
Content-Type: text/html; charset="US-ASCII"


<br><font size=2 face="sans-serif">Straight from the Help files....you're
going to need to declare the items as NotesDateTime items to do the comparison.
The simplest way is to extract them from an already declared NotesItem.
</font>
<br>
<br><font size=1><tt>Dim item As NotesItem<br>
Dim dateTime As NotesDateTime<br>
Set item = doc.GetFirstItem( &quot;DateComposed&quot; )<br>
Set dateTime = item.DateTimeValue</tt></font>
<p>
<p>
<p><font size=1><tt>Hope this helps,</tt></font>
<p><font size=1><tt>Don</tt></font>
<p><font size=2 face="sans-serif"><br>
&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;<br>
Don Shennum<br>
Technical Business Analyst<br>
Koret of California, Inc.<br>
505 14th Street<br>
Oakland, CA 94612<br>
(510) 622-7383<br>
***@koretsf.com<br>
http://www.koretsf.com<br>
&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;&lt;&gt;<br>
<br>
</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>***@averittexpress.com</b>
</font>
<br><font size=1 face="sans-serif">Sent by: lnotes-***@ozzie.notesnic.net</font>
<p><font size=1 face="sans-serif">10/08/2004 01:28 PM</font>
<table border>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
lnotes-***@ozzie.notesnic.net</font></div></table>
<br>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td><font size=1 face="sans-serif">Multiple recipients of list LNOTES-L
&lt;lnotes-***@ozzie.notesnic.net&gt;</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td><font size=1 face="sans-serif">Date/Time comparison in LotusScript</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=2><tt>Since this seems to be LotusScript day.<br>
<br>
I'm working on a project and I need to do a Do While loop until a <br>
particular date/time equals a second date time. How do I set up a <br>
comparison that in formula would be :<br>
<br>
@If(BeginTime = EndingTime;Stop;Keep Going)<br>
<br>
Every time I try a comparison in LS, I'm getting a type mismatch: and <br>
that's saving not running the script. I can't make claims to being a <br>
scripter, and time makes it worse.<br>
<br>
Brian<br>
</tt></font>
<br>
--=_alternative 001AD2C188256F2A_=--

Loading...