Calculate time difference in minutes

Santhana Rajhan
Mega Sage

I want a field to display the difference between two times in minutes.

find_real_file.png

Eg: Business Duration = 136

1 ACCEPTED SOLUTION

Hello Santhana


Please try below. g_form doesnot work server side



(function calculatedFieldValue(current) {



var dateString1 = new GlideDateTime(current.begin); //make sure variable name is begin


var dateString2 = new GlideDateTime(current.end); // make sure variable name is end


var diffSeconds = gs.dateDiff(dateString1, dateString2, true);


diffMins = diffSeconds/60;



return Math.round(diffMins);   // return the calculated value



})(current);



Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

20 REPLIES 20

I am unable to add this attribute.


An admin would need to add the attribute.   If you switch over to the 'advanced' view of the dictionary record you can just drop max_unit=minutes into the attributes field.


Something like this?



find_real_file.png


Back up a step.   In the dictionary record, in the 'related links' section right above the related lists, you should see an 'Advanced View' link.   Click that.   When the form reloads you'll see an 'Attributes' field.    


Screen Shot 2017-12-27 at 1.31.42 PM.png


This one too didnt work


find_real_file.png