Template for a math

image

I use the JavaScript column to do this. I’m abbreviating days as “d”, hours as “h”, mins as “m”.

if(p1) {

var delta = p1*24*60*60;

// calculate (and subtract) whole days
var days = Math.floor(delta / 86400);
delta -= days * 86400;

// calculate (and subtract) whole hours
var hours = Math.floor(delta / 3600) % 24;
delta -= hours * 3600;

// calculate (and subtract) whole minutes
var minutes = Math.floor(delta / 60) % 60;
delta -= minutes * 60;

// > 1 day

if(days >= 1) {
return days + "d " + hours + "h " + minutes + "m";
}

if(hours >= 1) {
return hours + "h " + minutes + "m";
}

else return minutes + "m";
}

Adapted from:

IIf you need to adjust it please tell me.

8 Likes