Rounding off using math floor function

Chandu12
Mega Expert

find_real_file.png

Logic has been written to calculate Days open field where 86400 is seconds for 1 day.

find_real_file.png

find_real_file.png

where math.floor is rounding off to 209.0

How can i remove this 0, what changes should be done in script.

Issue Details:

I'd like the "Days Open" field to only be integers and stop putting the additional .0 after the values.   We don't use it.

I also want to ensure this number field is able to be sorted appropriately and actually do numerical order smaller to largest and vice versa.   Right now, if I try to sort cases on Days Open they won't go in numerical order and go off the front number regardless of how high the number is (e.g., 209.0, 21.0, 211.0, 2112.0, 214.0).

1 ACCEPTED SOLUTION

Oh..okay, then may be you can use split method to get the value befor decimal point.


else


{


open1 = open1.toString().split('.'); // split with .


ffi1.u_days_open = open1[0];


}


View solution in original post

4 REPLIES 4

amaradiswamy
Kilo Sage

Hi Chalan,



You can try below



else


{


ffi1.u_days_open = open1.toFixed(0);


}


JavaScript toFixed() Method



Thanks and regards


Swamy


Hi Amaradi,



if i give "num.toFixed(0)" in my code this will round of.



Eg:


find_real_file.png find_real_file.png



where math.floor functionality is


find_real_file.png



Please correct me if anything going wrong in my code. any alternate solution is there to eliminate 0 after value.


Oh..okay, then may be you can use split method to get the value befor decimal point.


else


{


open1 = open1.toString().split('.'); // split with .


ffi1.u_days_open = open1[0];


}


Hi Amaradi,



thank you for your time and it was really helpfull.



Note: Please provide some good link to learn all this basic stuffs.



Regards,


chalan