I am having a probelm setting a date filed in my document, if I enter the number of days to adjust, then it is working but if I use a variable of a field value it does not work. here is the code I use. I have tried many ways…
Dim DaysToAdjust As Variant
DaysToAdjust = doc.DaysToStartQuiz(0)
StartNewDate = Evaluate("@Adjust(@today; 0; 0; 333; 0;0; 0)") ' this is working
’ StartNewDate = Evaluate(“@Adjust(@today; 0; 0; DaysToAdjust; 0;0; 0)”) ’ this is NOT working
Just add (or subtract) the number of days from your date.
BTW, for future reference, variables within the context of your script are not visible to the Evaluate formula. Only document fields are visible so you could have done:
Set ndt = New NotesDateTime("Now")
StartNewDate = doc.DaysToStartQuiz(0)
Call ndt.AdjustDay(333 )
' Call ndt.AdjustDay(StartNewDate)
Call ndt.SetAnyTime
Call doc.ReplaceItemValue("DateFailed", 333)' this works
' Call doc.ReplaceItemValue("DateFailed", ndt)' this does notworks
You can NOT set the value of a field to an object (which is what ndt is) - you would have to get the object’s LSLocalTime property. By the way, what was wrong with using my previous suggestion:
StartNewDate = Today() + DaysToAdjust
that had no need to construct a NotesDateTime object. In fact, now that I see the rest of your code, you can do all of the work above in one line of code:
Good - I’m glad that we can exchange knowledge. I suppose you can see now that what I meant by not using Evaluate does not necessitate using NotesDateTime.