Illegal Function Call after ND6 Upgrade

Since upgrading server to ND6, I am getting an “Illegal function call” error on a scheduled agent. I have narrowed it down to the following line of code:

Call logbody.AppendText( starttime.DateOnly & " " & starttime.TimeOnly & " " & Format$(Timevalue(elapse)*1440,“Fixed”) & " MINUTES IN “”" & maildb.title & “”“, " & testword$ & Str$(n) & " MESSAGES OUT OF " & Str$(doctotal) & " DOCUMENTS.”)

Can anyone tell me, please, what is wrong? It writes the date and time into the log doc and then writes “Error5: Illegal function call”

Thanks in advance.

Subject: How do you set ‘elapse’?

Subject: RE: How do you set ‘elapse’?

Dim elapse As VariantDim starttime As New notesdatetime(“”)

starttime.SetNow

elapse = Now - starttime.LSLocalTime

Subject: RE: How do you set ‘elapse’?

If I remove the “Timevalue” function and run it with just:

Format$(elapse*1440,“Fixed”)

it appears to run properly?

Subject: RE: How do you set ‘elapse’?

From R6 help;

Syntax

TimeValue ( stringExpr )

Elements

stringExpr

A string expression that represents a valid date/time, or a Variant of DataType 7 (Date/Time). It can use either 12-hour or 24-hour format; for example, both “14:35” and “2:35PM” are valid. If you omit the seconds value in the stringExpr argument, it defaults to zero (0).

I would suspect that since elapsed is not a date/time value (it only represents the number of seconds elapsed), TimeValue is throwing an error.

I created a test agent with same code and this is the value I get for elapse

1.15740767796524E-05

which to the best of my knowledge is not a valid date/Time value. In R5, since this is not a valid date/time error, timevalue(invaliddatetime) returns 12:00:00 AM.

This is clearly a case where R6 is definitely correct, but its correctness is causing older code to break.