Why is @Month returning day in view column populating a Date/Time field in LotusScript?

86 Views Asked by At

I am using LotusScript to populate a date/time field in a Lotus Notes document. Here is the code that I am using:

Dim dtItem As NotesItem
Set dtItem = endorsementDoc.GetFirstItem("EndorsementEffectedDate")
Dim paymentDue As NotesDateTime
Set paymentDue = dtItem.DateTimeValue
Call paymentDue.AdjustDay(45)
idoc.PaymentDue = paymentDue.DateOnly

The EndorsementEffectedDate field is a date/time field that is populated by the user. I want to set the PaymentDue field to 45 days after the EndorsementEffectedDate. To do this, I am using the AdjustDay method of the NotesDateTime class.

The problem is that when I set PaymentDue to paymentDue.DateOnly, the @Month formula returns the day of the month instead of the month itself. For example, if EndorsementEffectedDate is 20/04/2023 and I add 45 days, PaymentDue is set to 04/06/2023 but @Month(PaymentDue) returns 4.

The column formula for month is @Month(@TextToTime(@Text(PaymentDue)))

Why is @Month returning the day instead of the month? How can I get the correct month value in LotusScript?

I checked the Windows servers date/time settings and they are set correctly.

I also tried using the Format function to explicitly make the date in the format "dd/mm/yyyy" but the issue still persists.

3

There are 3 best solutions below

2
Emmanuel Gleizer On BEST ANSWER

@Month returns really the month. But you must check the date format you put in you field when:

idoc.PaymentDue = paymentDue.DateOnly

Your date format is (probably) MM/DD/YYYY : for example 04/20/2023. And 06/04/2023 when you add 45 days.

@Month is based on your regional settings and return 04. Do not store your PaymentDue as a string, but as a real Date Time:

idoc.PaymentDue = paymentDue.LSLocalTime

Other possibility : your lotuscript code run on your machine with a DD/MM/YYYY format (and the PaymentDue is in this string format). But the view is calculated on the server that has a MM/DD/YYYY regional setting.

0
Rob Mason On

After your lotusscript code that you show has run, are you saving the document?

E.g

Call iDoc.save(false, false)

If you are, then I think your view column may be corrupt. Try deleting it and create a new column with the same formula.

0
Richard Schwartz On

It appears that you want to make sure that the time component is stripped from the adjusted EndorsementEffectedDate.

This line does it, but...

idoc.PaymentDue = paymentDue.DateOnly

... It is setting idoc.PaymentDue as a text field. As per the help for the DateOnly method, it returns a string.

If you want it to be treated as a date, you should instantiate another NotesDateTime object from paymentDue.DateOnly and assign this new object to idoc.PaymentDue.