Re: Fc Calculation or JS for time formate calculation (274 Views)
Reply
Frequent Advisor
Posts: 51
Registered: ‎08-20-2013
Message 1 of 4 (332 Views)

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.

Honored Contributor
Posts: 5,881
Registered: ‎11-10-2008
Message 2 of 4 (312 Views)

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
Posts: 51
Registered: ‎08-20-2013
Message 3 of 4 (286 Views)

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.

 

 

Honored Contributor
Posts: 5,881
Registered: ‎11-10-2008
Message 4 of 4 (274 Views)

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

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.