With Flokzu, creating a calculated field that at all times displays the difference (in hours) between 2 Time fields is super easy.

Step 1
Add two Time fields (e.g. 'Time A' y 'Time B').

Step 2
Add a calculated field (e.g.: 'Difference')

Step 3
Add the following script to the calculated field

calcDiff();

function calcDiff(){
var m1 = moment( Flokzu.getFieldValue([[Time A]]) , “HH:mm:ss”);
var m2 = moment( Flokzu.getFieldValue([[Time B]]), “HH:mm:ss”);

if(m1.isBefore(m2)){
return (moment.utc(m2.diff(m1)).format(“HH:mm:ss”));
}else{
return (moment.utc(m1.diff(m2)).format(“HH:mm:ss”));
}
}


The format of the result is 'HH:mm:ss' but that can be customized (e.g. just display 'HH:mm').

Resultado

Difference between two times
Was this article helpful?
Thank you!