With the following fields: DateWorked with a format of d-mmm-yyyy StartTime with a format of h:MM tt EndTime wit a format of h:MM tt Your custom calculation script could be: event.value = ""; // clear result; var cDateFormat = "d-mmm-yyyy"; // format for date field; var cTimeFormat = "h:MM tt"; // format for time fields; var cDateWorked = this.getField("DateWorked").valueAsString; // get date worked; var cStartTime = this.getField("StartTime").valueAsString; // get start time; var cEndTime = this.getField("EndTime").valueAsString; // get end time; if(cDateWorked != "" && cStartTime != "" && cEndTime != "") { // compute worked time only if we have data; var oStartDateTime = util.scand(cDateFormat + " " + cTimeFormat, cDateWorked + " " + cStartTime); // start date time as Date object; var oEndDateTime = util.scand(cDateFormat + " " + cTimeFormat, cDateWorked + " " + cEndTime); // end date time as Date objec; if(oStartDateTime != null && oEndDateTime != null){ // compute only if we have valid date and time combination; // the time difference is reported in minutes; event.value = Math.floor((oEndDateTime.getTime() - oStartDateTime.getTime()) / (1000 * 60)); // compute worked time as minutes; // displayed vlaue is set in the custom format script, so the total of all time can be computed in minutes; } } Your custom format script could be: if(event.value != "") { // display format as hours and minutes; event.value = util.printf("%,101d:%,102d", Math.floor(event.value / 60), (event.value % 60)); } This approach for the form will allow one to accumulate the total time worked if there are multiple days included to be computed in minutes and then use the custom format to format the displayed result.
... View more