Hi Markus,



Thanks a lot for your response. It providing time in seconds in proper way. But in hours it is not calculating properly.


  1. var dur_seconds = gs.dateDiff(start, end, true); // returns a String  
  2. var dur_hours = Math.round(dur_seconds / 60 / 60);  
  3. gs.print(dur_hours);

In above part if dur_seconds = 2400 second


then dur_hours = 1


while it should provide 2400/60/60 = 2/3 = .66



Please help.



Thanks,


Sourabh


Try changing "(dur_seconds / 60 / 60)" to "(dur_seconds / 3600)"



Also, if you're doing "Math.round()" then .66 rounded = 1.


Hi Dave,



Yes , "Math.round()" then .66 rounded = 1.


Which function should I used to get value decimal format that .66 form.



Thanks,


Sourabh


Hi Sourabh



Do you need a specific number of decimals? Otherwise you can just remove the "Math.round()" function.



var dur_seconds = 2400;


var dur_hours = dur_seconds / 3600;


gs.print(dur_hours); // *** Script: 0.6666666666666666



The example above is updated.



Best regards


Markus


Possibly parseFloat() - check the Javascript documentation for the Math and Number classes.