Date Comparison Problem in Schedule Agent

I have a scheduled agent that works fine when triggered manually but fails when changed to run on schedule. I have checked all of Julie’s FAQ’s on agents and security and thue use of UI classes and none of these is the issue. I have searched both the R4/5 and R6 forums and have not found a solution to my problem. Perhaps I have been staring at the same code for too long and I am simply missing it. Code snippet is posted below. Any help would be greatly appreciated.

Tim

If Not (attydoc Is Nothing) Then

	Call agentLog.LogAction("Found Attorney")

	taskdate = doc.TaskDate(0)

	For i = 0 To Ubound(attydoc.DateRanges)		

		Set dateRange = s.CreateDateRange

		dateRange.Text = attydoc.DateRanges(i)

		Set fromDate = dateRange.StartDateTime

		Set toDate = dateRange.EndDateTime

		Call agentLog.LogAction("Checking Date Range: " & dateRange.Text)

		Call agentLog.LogAction("Task Date Used: " & taskdate)

		Call agentLog.LogAction("From Date Used: " & fromDate.LocalTime)

		Call agentLog.LogAction("To Date Used: " & toDate.LocalTime)

		If (taskdate >= fromDate.LocalTime) And (taskdate <= toDate.LocalTime) Then

			Call agentLog.LogAction("TaskDate within Range")

			Call doc.ReplaceItemValue("Total", Cstr(attydoc.RateTable(i) * Cdbl(doc.Hours(0))))

			Call agentLog.LogAction("Found Rate and updated Total")	

		Else

			Call agentLog.LogAction("Failed Date Range Check")

		End If	

	Next

End If

Subject: Date Comparison Problem in Schedule Agent

code runs fine manuallyfails on schedule

first things I check are as follows:

  • (if signed by you) check server settings to confirm that you have rights to run unrestricted LS agents

  • sign the agent with the server ID and try it

  • check the agent properties for any inconsistencies

I know these are academic but its a good place to start