datedatetimeviewlotus-dominolotusscript

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


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.


Solution

  • @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.