Systime

I inherited a db from someone and now I’m trying to fix a problem with the time stamp. There is an agent that runs that has this as part of the code:

Set scheditem = doc.ReplaceItemValue(“sysdate”, sysTime)

However, when it places the date and time stamp on the document, the date is current but the time is ahead by 15 hours. The OS time shows current mo/day/yr. and the timezone is set to the correct (Pacific) one. I can’t figure out where it is pulling this future time from. I know nothing about Lotus Script, so don’t even know what I’m looking at or looking for.

Any ideas?

Thanks for your responses

Helen

Subject: systime

you have to go thru the code and look for systime, and that will tel you what value they are using. for examply they may have defined the field system time, and then used an adjustHour of 15 to put it ahead.

John

natually you can post all of code, that would help us.

Subject: RE: systime

John,Thanks for your response.

Here is the entire code:

Sub Initialize

On Error Resume Next

Dim db As Notesdatabase

Dim session As New NotesSession

Dim newsess As NotesSession

Dim database As NotesDatabase

Dim view As NotesView

Dim ptoview As NotesView

Dim doc As NotesDocument

Dim timedoc As NotesDocument

Dim VNAME As String

Dim recipients( 1 To 3 ) As String

Dim ename(30) As String

Dim a As Integer

Dim b As Integer

Dim col As NotesDocumentCollection

Dim dateTime As New NotesDateTime("Today")

Dim sysTime As New NotesDateTime("Today")

Dim startweek As New NotesDateTime( "01/02/2000" )

Dim currweek As New Notesdatetime( "")

Dim query As String

Dim query1 As String

Dim query2 As String

Dim success As Variant

Dim scheditem As NotesItem

Dim crlf As String

Dim recea As String

Dim deptid As String



crlf = Chr$(10) & Chr$(13)



Set db = session.CurrentDatabase        



Set newsess = New NotesSession

Set database = newsess.CurrentDatabase

If db.IsFTIndexed Then    'If a full text index is set

	Call db.UpdateFTIndex(True)  'Update the index

End If



Print "********** RECALCULATE agent is now beginning.*************"



VNAME = "GoodRecords"

Set view = database.GetView(VNAME)

Set ptoview = database.GetView("PTOYTD")

Set doc = view.GetFirstDocument

' Calculate the PTO time used Year to date



Do While Not( doc Is Nothing ) 'Do this loop until there aren't any more documents

	

	a = a + 1

	b = b + 1

	ssn = doc.SocialSecurity(0)

	Set col = ptoview.GetAllDocumentsByKey(ssn, False)

	ptotal=0

	vtotal=0

	If col.Count > 0 Then

		For I = 1 To col.Count

			Set timedoc= col.GetNthDocument( I )

			ptotal = ptotal + timedoc.ptotal(0)

		Next

		standhour = doc.standhours(0)

		doc.perused = ptotal

		

		ptoaccum = doc.peraccum(0)

		ptoman = doc.ptomanual(0)

		

		If Isnumeric(ptoman) Then

		Else

			ptoman = 0

		End If

		doc.peravail = ptoaccum - ptotal - ptoman

		b = b + 1

’ success = doc.ComputeWithForm( False, False )

		Set scheditem = doc.ReplaceItemValue("sysdate", sysTime)

		Call doc.Save( True, True )

	End If

	

	Set doc = view.GetNextDocument(doc)

	

Loop

'  now calculate the SLP time off used Year to Date



i = 0

Set ptoview = database.GetView("SLPYTD")

Set doc = view.GetFirstDocument

Do While Not( doc Is Nothing ) 'Do this loop until there aren't any more documents

	

	a = a + 1

	b = b + 1

	ssn = doc.SocialSecurity(0)

	Set col = ptoview.GetAllDocumentsByKey(ssn, False)

	vtotal=0

	If col.Count > 0 Then

		For I = 1 To col.Count

			Set timedoc= col.GetNthDocument( I )

			vtotal = vtotal + timedoc.vtotal(0)

		Next

		standhour = doc.standhours(0)

		doc.vacused = vtotal

		vacaccum = doc.vacaccum(0)

		slpman = doc.slpmanual(0)

		If Isnumeric(slpman) Then

		Else

			slpman = 0

		End If

		doc.vacavail = vacaccum - vtotal - slpman

		b = b + 1

’ success = doc.ComputeWithForm( False, False )

		Set scheditem = doc.ReplaceItemValue("sysdate", sysTime)

’ If doc.manager(0) = “” Then

’ doc.manager = doc.deptea(0)

’ End If

		Call doc.Save( True, True )

	End If

	

	Set doc = view.GetNextDocument(doc)

Loop



Print "**********  refresh agent complete. Records processed by the agent: " & Str$(a) & "  Records updated by agent = " & Str$(b) & "    ********************"

End Sub

Subject: RE: systime

sysTime uses “Today” as its value. If the NotesDateTime object is allowed to have a time component and the time component is not explicitly set, that time will be midnight (start of day).

Use the following to set the correct time:

Call sysTime.SetNow

Subject: RE: systime

Stan,Thanks for the response. I’m not a developer and don’t have a clue about LS. Forgive the simple question, but exactly where in all that code do I insert what you suggested (Call sysTime.SetNow)?

Thanks again

Helen

Subject: RE: systime

Helen,

Right after the CRLF Statement, just put in what Stan says…

call sysTime.setNow (I think that is what he had).

The dim statement set the save, but you can not trim the time in the same statement.

as a fyi, you should modify the code to get rid of the .getNthDocument, that is the slowest say to get documents back.

John

Subject: RE: systime

Make it the first line AFTER this one:

Do While Not(doc Is Nothing)

On second thought – change that line to:

Do Until doc Is Nothing

while you’re at it. It’s a lot easier to read than the existing version, and it means exactly the same thing.