How to convert duration field to a string value?

malaisamy1
Kilo Contributor

Hi Guys,

My problem is: I want to subtract two date/Time field and the result should stored in another field.

This i have achieved through this code using Business Rule.

"var gdt1 = new GlideDateTime(current.initial_response_date_time.getDisplayValue());  

var gdt2 = new GlideDateTime(current.open_date_time.getDisplayValue());  

var dur = GlideDateTime.subtract(gdt2, gdt1); //the difference between gdt1 and gdt2  

var dur1= new GlideDuration();  

dur1.setValue(dur.getValue());  

current.si_actual_response_duration=dur1.getDurationValue(); "

But the problem is i need to convert this duration field to seconds and this has to be stored in another field.

And also i have one more problem with this script is, the result gives me the duration along with date like this. "1970-01-01 01:00:00"

Can someone help me to resolve this issue?.

My Need is: Two date and time field has to be subtracted and the result should stored in another field as seconds.

Thanks in advance for the help.

Malaisamy J

1 ACCEPTED SOLUTION

sushantmalsure
Mega Sage
Mega Sage

the result you need to store in another field if that is a date/time field then 1970-01-01 01:00:00 is a valid value to store 1 hour.


what's the type of field?


If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

View solution in original post

11 REPLIES 11

share complete code of business rule.


and confirm the value of severity_priority is it '1-critical' or is 1?


If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Sorry,



Its working.. I have used this idea in client script.. Thanks for the help