Support » Plugin: Calculated Fields Form » Return time in minutes

• Resolved Jonathan

(@bionicsquid)

I’m using the second formula:
(function(){
var date1 = new Date(fieldname1*86400000),
date2 = new Date(fieldname2*86400000),
s = ABS(date1-date2)/1000,
h = FLOOR(s/3600);
m = FLOOR((s%3600)/60);
return h+’:’+m;
})()

The time is returned in hours and minutes, and I need the time returned just in minutes. Can you suggest an edit to the formula that will show total minutes?

Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
• Plugin Author codepeople

(@codepeople)

Hello @bionicsquid

If you want the result in minutes the process would be simpler. In your equation, the “s” variable is number of seconds, and 1 minute = 60 seconds, so, the answer would be `s/60`:

``````
(function(){
var date1 = new Date(fieldname1*86400000),
date2 = new Date(fieldname2*86400000),
s = ABS(date1-date2)/1000;
return FLOOR(s/60);
})()
``````

and that’s all.
Best regards.

(@bionicsquid)

I was able to get minutes returned by changing h= to /60 instead of 3600 and then returning only h below. If there’s a better way please suggest. Thanks.

Plugin Author codepeople

(@codepeople)

Hello @bionicsquid

Please, read my previous entry, the equation returns the number of minutes.

Best regards.

(@bionicsquid)