Service Manager / Service Center Practitioners Forum
Showing results for 
Search instead for 
Do you mean 

Fc Calculation or JS for time formate calculation

Frequent Advisor

Fc Calculation or JS for time formate calculation

Hi Experts,

 

In Incident ticket am calculating outage like Outage=Downtime End - Downtime Start and am getting output in 3 15:36:00 this format. 3 days 15 hrs 36 min.

 

I have a requirement of calculating outage below format

87:36:00

(3*24) + 15 = 87

 

Please help me with FC calculation or a java script to achieve the above requirement.

 

Thanks in Advance.

3 REPLIES
Honored Contributor Honored Contributor

Re: Fc Calculation or JS for time formate calculation

Not sure if there is easy way to do that (can not imagine of any atm) but you could cut last 9 symbols from it (it will leave only days for you ) to multiply by 24 and then cut 6 symbols to get the hour part. There might be a function to do that normally but i can not revise any.

Frequent Advisor

Re: Fc Calculation or JS for time formate calculation

Hi Vadim,

 

Thanks for your reply.

 

Am new for JS, can you please help me by giving the detailed JS.

 

 

Highlighted
Honored Contributor Honored Contributor

Re: Fc Calculation or JS for time formate calculation

Hello,

Here is a bit "clumsy" solution but it should work for you

 

var fstring= vars.$file.FIELD_NAME;
vars.$length = system.functions.lng(fstring);
var fstringhead=fstring.slice(0,vars.$length-9);
var fheadhours=fstringhead*24;
var fstringend=fstring.slice(vars.$length-8,vars.$length-6);
vars.$file.FIELD_TO_RECORD_RESULT=fheadhours*1+fstringend*1;

 

 

Instead of FIELD_NAME input the name of the field which carries value 3 15:36:00 (if the field name has "." replace them with "_" like in my example)

 

In the end instead of FIELD_TO_RECORD_RESULT set the field name in which must be recorded 87.

 

 

This should be put to the format control JS tab as it works with $file variable