• Hi Ben,

this should work:

``````var closeTime = moment();
var createdTime = moment(@Created On);
var timeDiff = (closeTime.diff(createdTime,'minutes')/60).toFixed(2);

@Status == 'Closed' ? timeDiff : 0;
``````

If createdTime = 14:07 and closeTime = 17:27 you'll get the result = 3.33 hours (= 3 h 20 m). The result is a number so you can use this value for further calculations). "toFixed(2)" sets the decimals .

If you don't need the value for further calculations, try:

``````var closeTime = moment();
var createdTime = moment(@Created On);
var timeDiff = closeTime - createdTime;

moment(timeDiff).format("hh [Hours] mm [Minutes]")
``````

result = 03 Hours 20 Minutes (but the value is a text string and it's not so easy to do further calculations with it)

Rainer
rg@delos-consulting.com

• Using the Second Method it always starts the time from 12:00. How can I amend it to start from 0:00. Also is there a way to add day's to it after the time take has passed the 24:00 mark?

• Try this one. If days, hours or minutes = 0, it doesn't show this unit.

``````var closeTime = moment();
var createdTime = moment(@Created On);
var timeDiff = closeTime - createdTime;

var dCount = moment.duration(timeDiff).days();
var hCount = moment.duration(timeDiff).hours();
var mCount = moment.duration(timeDiff).minutes();

var dText = dCount > 0 ? dCount + " Days " : "";
var hText = hCount > 0 ? hCount + " Hours " : "";
var mText = mCount > 0 ? mCount + " Minutes" : ""

var result =  dText + hText + mText

@status == "Closed" ? result : ""
``````

Rainer
rg@delos-consulting.com

• what if he wanted to calculate the time between In-progress and Closed?