cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

DownTime duration in hours not displaying the minutes

Janicen
16-Pearl

DownTime duration in hours not displaying the minutes

Hi community,

 

I am trying to display duration (difference between 2 dates). I converted it from decimal hours to hours.

The problem I am now facing is the minutes are not displaying. The duration only changes after an hour. 

 

Below is the code that I have written. Does someone know How I can solve this problem. 

 

var decimalTime = parseFloat(duration);
decimalTime = decimalTime * 60 * 60;
var hours = Math.floor((decimalTime / (60 * 60)));
decimalTime = decimalTime - (hours * 60 * 60);
var minutes = Math.floor((decimalTime / 60));
decimalTime = decimalTime - (minutes * 60);
var seconds = Math.round(decimalTime);
if(hours < 10)
{
hours = "0" + hours;
}
if(minutes < 10)
{
minutes = "0" + minutes;
}

let result = ("" + hours + ":" + minutes);

 

The desired output should be e.g., 16:00. Then after two minutes I should see 16:02. However currently I am only seeing a change after an hour (i.e. 17:00 after sixty minutes).

 

Many thanks

ACCEPTED SOLUTION

Accepted Solutions

I found out why I was not getting the correct output.

 

On my grid configuration settings, I had to click on column render and then change the duration column data type from number to string. 

This is because I am outputting the duration as a string and in the data shape the column is also of a string data type. But in the mashup composer, I previously set it to display as a number, which was wrong. It should have been rendered as a string.

 

View solution in original post

1 REPLY 1

I found out why I was not getting the correct output.

 

On my grid configuration settings, I had to click on column render and then change the duration column data type from number to string. 

This is because I am outputting the duration as a string and in the data shape the column is also of a string data type. But in the mashup composer, I previously set it to display as a number, which was wrong. It should have been rendered as a string.

 

Announcements


Top Tags