# Template for a math

**URL:** <https://community.glideapps.com/t/template-for-a-math/40671>\
**Category:** Ask for Help\
**Created:** [April 12, 2022, 11:54pm UTC](https://community.glideapps.com/t/template-for-a-math/40671 "2022-04-12T23:54:11Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [April 13, 2022, 12:27am UTC](https://community.glideapps.com/t/template-for-a-math/40671/3 "2022-04-13T00:27:26Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/3/c32a0940d424a75444402fffb4add5af60bdc0d1.png)

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

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/0/20540dffaece27547a41f397fed3b9331bad26c2.png)

```auto
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:

> <https://stackoverflow.com/questions/13903897/javascript-return-number-of-days-hours-minutes-seconds-between-two-dates/13904120#13904120>

IIf you need to adjust it please tell me.

---

_[View the full topic](https://community.glideapps.com/t/template-for-a-math/40671)._
