Adding TimeDifference to a numeric field

I have a form with two date fields. An action on the form calculates the timeDifference between these two fields. As this action can be done many times, I have a numeric field to keep a running total of the timeDifference calculated. The timeDifference is being calculated ok, but when I try and add this to my numeric field, I get ‘Type mismatch’.

Dim time1 As New NotesDateTime(doc.fld_Time1(0))

Dim time2 As New NotesDateTime(doc.fld_Time2(0))

time3= time1.timeDifference(time2)/60

doc.fld_Total_Time= (doc.fld_Total_Time + time3)

I have tried everything but can’t get the time value to add on to the Total Time field. Any ideas would be greatly appreciated.

Subject: Adding TimeDifference to a numeric field

When you get the “old” time value from the field, you should use:

doc.fld_Total_Time(0)

since this field is a list of values (you can check this in the debugger) even if it only contains a single value.

Subject: RE: Adding TimeDifference to a numeric field

Rob

I have changed my code to the following

Dim time1 As New NotesDateTime(doc.fld_Time1(0))

Dim time2 As New NotesDateTime(doc.fld_Time2(0))

time3= time1.timeDifference(time2)/60

doc.fld_Total_Time= (doc.fld_Total_Time(0) + time3)

This has got rid of the ‘Type mismatch’ error, but is not storing the new value for me in the fld_Total_Time field.

Subject: RE: Adding TimeDifference to a numeric field

Hi Rob

Ignore last reply, value is calculating fine for me now. Thanks for your help.