I need the below to include seconds in the output field. I have looked everywhere and I'm sure simple. Please help.
if (HasValue(startsamplingtime) and HasValue(endsamplingtime)) then
var TimeDiff = (Time2Num(endsamplingtime.formattedValue, "HH:MM:SS") - Time2Num(startsamplingtime.formattedValue, "HH:MM:SS")) / (1000 * 60 * 60)
//truncate to hours
var HourDiff = Floor(TimeDiff/60)
//get minutes less than 60
var MinDiff = Mod(TimeDiff,60)
need seconds here
var SecDiff =
// build fomatted dispaly string
Concat( Format("Z9", HourDiff), ":", Format("99",MinDiff), ":", Format("99", SecDiff) )
else
// if any values missing null the output
null
endif
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Try something like;
if (HasValue(startsamplingtime) and HasValue(endsamplingtime)) then
var millisecondsPerMinute = 1000 * 60;
var millisecondsPerHour = millisecondsPerMinute * 60;
var interval = Time2Num(endsamplingtime.formattedValue, "HH:MM:SS") - Time2Num(startsamplingtime.formattedValue, "HH:MM:SS");
// Calculate the hours, minutes, and seconds.
var hours = Floor(interval / millisecondsPerHour );
interval = interval - (hours * millisecondsPerHour );
var minutes = Floor(interval / millisecondsPerMinute );
interval = interval - (minutes * millisecondsPerMinute );
var seconds = Floor(interval / 1000 );
Concat( Format("Z9", hours), ":", Format("99",minutes), ":", Format("99", seconds))
endif
Regards
Bruce
Views
Replies
Total Likes
Hi,
Try something like;
if (HasValue(startsamplingtime) and HasValue(endsamplingtime)) then
var millisecondsPerMinute = 1000 * 60;
var millisecondsPerHour = millisecondsPerMinute * 60;
var interval = Time2Num(endsamplingtime.formattedValue, "HH:MM:SS") - Time2Num(startsamplingtime.formattedValue, "HH:MM:SS");
// Calculate the hours, minutes, and seconds.
var hours = Floor(interval / millisecondsPerHour );
interval = interval - (hours * millisecondsPerHour );
var minutes = Floor(interval / millisecondsPerMinute );
interval = interval - (minutes * millisecondsPerMinute );
var seconds = Floor(interval / 1000 );
Concat( Format("Z9", hours), ":", Format("99",minutes), ":", Format("99", seconds))
endif
Regards
Bruce
Views
Replies
Total Likes
Thanks! That work perfectly! My scripting is limited and had already tried multiple codes.
Brandi
Views
Replies
Total Likes
If I want to add in the day for instances that run over would I have to combine date/time field and do calculation or is there a way I could calculate separately and then concatenate?
Thanks
Views
Replies
Total Likes