lotus-dominolotus-formuladomino-designer-eclipse

Difference between two date/time field to calculate remaining days - Lotus Notes


I have a Form and I want to calculate the remaining days for a warranty.

Below here are some similar with me but not meet my full requirement as they only calculate remaining without updated days. Difference between two date/time fields - Lotus Notes

So, below is the function I have tried. For field1, I'm using @Today. For field2, I'm using @Modified. But if I use @Modified, it will set a date as last day I modified the document. I check example from https://www.ibm.com/support/knowledgecenter/en/SSVRGU_8.5.3/com.ibm.designer.domino.main.doc/H_EXAMPLES_CREATING_A_FIELD_TO_DISPLAY_DATES_AND_TIMES.html they use @Created as when document creates and @Now as today date.

Field1() will set today date and will update every day.

@Today

Field2 will be set by the user.

@Modified

Field3 will show the remaining days.

@Abs(@Integer((PDateEnd - PCurrentDate) / (86400)))

I want to display the remaining days with update days. For example, today 25/03/2019 to 27/03/2019 is 2 days. When the day update to 26/03/2019 to 27/03/2019 is 1 day. I am trying to make one field with update day and another field set the last day. Please suggest anything. Thank you in advance.


Solution

  • I take the answer from Torsten Link and umeli.

    I set the field to Computed for display as it computes on Open of a document in read mode. Because I only use @Function for the field and not using any agent.

    As I set as below to get the difference of two dates:

    Field1 (set as computed)

    @Today
    

    Field2 (set as editable because I want the field to be edit)

    @Modified
    

    Field3 (set as computed for display as it only for read mode) and there are two method.

    @Abs(@Integer((PDateEnd - PCurrentDate) / (86400)))
    

    and

    @Abs(@Integer((CurrentDate - DateCreated) / (60 * 60 * 24)))
    

    If you do not want to set @Today, you can set field1 as "date1" and field2 as "date2". And for field3 you can set as "(date2-date1)/86400"