Calculated time diff between two Duration fields

sreenivas8
Tera Contributor

Hi All,

 

I have two customized duration fields 1. Time elapsed in duration 2. On hold duration.

 

Now my requirement is, I need to calculate time difference between above two duration fields and insert the output to another duration filed i.e MTTR.   

MTTR= Time elapsed duration minus on hold duration.

 

Pls note,here all the field types are duration only.

 

I'm try with below update BR, but not getting desired input. pls help me.

 

sreenivas8_0-1689096728983.png

 kindly refer below snap as well...

Here my desire output is MTTR= Time elapsed minus on hold duration, then value(MTTR) should be 1 day 1 hour but here value I'm getting as empty. 

 

sreenivas8_1-1689096956643.png

 

 
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@sreenivas8 

try this

var dura = current.u_time_elapse.dateNumericValue();
var durb = current.u_on_hold_duration.dateNumericValue();
current.u_mttr_of_mi.setDateNumericValue(dura - durb);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

@sreenivas8 

Glad to help.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks alot @Ankur Bawiskar - it really helped me as well.