0

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.

Reinhaa
  • 195
  • 1
  • 17
  • 2
    What type are your fields ?Computed or Computed for Display? Computed does not update automatically, it needs a document refresh. – umeli Mar 25 '19 at 07:28
  • @umeli My field only computed. Should I change to computed to display? – Reinhaa Mar 25 '19 at 07:29
  • Sure. Then it will be always computed when it displays :-) – umeli Mar 25 '19 at 07:30
  • @umeli Where should I put that computed for display? Should I put it on Field3? – Reinhaa Mar 25 '19 at 07:33
  • 1
    Computed and Computed for display field calculate at the same time: they both need a document refresh to be calculated. Only difference: Computed for display (CFD) compute on Open of a document in read mode as well while Computed only calculate in edit mode. AND: CFD fields are NOT stored in the document, therefor cannot be used in views. – Tode Mar 25 '19 at 07:58
  • @TorstenLink So, is it better for me to use computed or computed for display? I'm just thinking to use computed only. – Reinhaa Mar 25 '19 at 08:10
  • 1
    If you need the value in a view or agent, then use computed. If you just need the value in the form for display, then use the computed for display field. If you use computed fields, then you need to refresh it. – umeli Mar 25 '19 at 08:38
  • Okay, I understand now. Thank you for clarification. Will update it. – Reinhaa Mar 25 '19 at 08:43
  • @BusinessDays is your friend here! – Travis Hiscock Jul 25 '19 at 15:41

1 Answers1

0

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"

Reinhaa
  • 195
  • 1
  • 17