Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
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
Solved! Go to Solution.
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.
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.