Individual Time Calculation
- July 10, 2020
- 3 replies
- 2420 views
Hi
Looking for some help.
I found and copied a script to calculate the time spent on a task from 'on' to 'off'. I need this total on each row but I can't figure out why it is causing errors with certain time periods.
I have adjusted the script for each cell, Time 3.0/3.1/3.2 etc
It doesn't matter which row I enter the times in question they always calculate wrong.
Any ideas what I am doing wrong?
Angie
TIA
var start = this.getField("Time 3.0").value;
var startArr = start.split(":") ;
var finish = this.getField("Time 4.0").value;
var finishArr = finish.split(":");
var hourDiff = Math.abs(finishArr[0] - startArr[0]);
var minDiff = Math.floor((Math.abs(finishArr[1] - startArr[1]) / 60)*100);
if (minDiff.toString().lenght == 1)
minDiff = '0' + MinDiff;
var output = hourDiff + "." + minDiff;
event.value = output;
