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

Interesting.   Works on my instance:


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


Ah, remove the semicolon and it'll work.


Tried both the ways,


find_real_file.png


Do you need to capture the result in separate custom field?


Yes.