Currently our data displays in seconds, but I'd like to set it to display in minutes, hours, or days so that it's easier to read in the pop-up. How can I accomplish this with Arcade?
Solved! Go to Solution.
Have a look at the example below:
var seconds = 90061;
var result = "";
var days = Floor(seconds / (60 * 60 * 24));
if (days > 0) {result = Round(days,0) + " day(s) "};
seconds -= days * 60 * 60 * 24;
var hours = Floor(seconds / (60 * 60));
seconds -= hours * 60 * 60;
var minutes = Floor(seconds / 60);
seconds -= minutes * 60;
result += Text(hours, "00") + ":" + Text(minutes, "00") + ":" + Text(seconds, "00");
return result
This returns:
1 day(s) 01:01:01
Just assign the seconds field to the seconds variable on line 1.
Have a look at the example below:
var seconds = 90061;
var result = "";
var days = Floor(seconds / (60 * 60 * 24));
if (days > 0) {result = Round(days,0) + " day(s) "};
seconds -= days * 60 * 60 * 24;
var hours = Floor(seconds / (60 * 60));
seconds -= hours * 60 * 60;
var minutes = Floor(seconds / 60);
seconds -= minutes * 60;
result += Text(hours, "00") + ":" + Text(minutes, "00") + ":" + Text(seconds, "00");
return result
This returns:
1 day(s) 01:01:01
Just assign the seconds field to the seconds variable on line 1.
This worked great! Thanks!
Hi jakecaldwell_ETISoftware , I'm glad it does. You can tweak the way you want to present the results. If you have any additional questions, just post them here and I will get back to you.