Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Calculating Total Number of Days +1

Avatar

Former Community Member
I'm have two Date/Time fields, one for "StartDate" and one for "EndDate".

I then have a Numeric "TotalDays" field which calculates the total number of days from "StartDate" to "EndDate".



I used the following calculation formula in the "TotalDays":



Date2Num(EndDate, "YYYY-MM-DD") - Date2Num(StartDate, "YYYY-MM-DD") + 1



The problem with it is, I have to add "1" to get the right total number of days, which results with "1" showing up in the Numeric field in the form.



Is there another calculation method I can use to avoid showing the number "1" or is there a way of hiding it?



Thanks!
1 Reply

Avatar

Level 1

if (StartDate=="" || EndDate=="") event.value = "";

else {

  // do the rest of the calculation

}