Difference of two date/time type fields should populate in Duration type field

RC19
Tera Contributor

We have two date/time type fields and the requirement is to capture the difference of these date/time fields into a duration type field . I have written business rule and i am getting subtraction value in seconds or days 00:00:00 format using script but if i set that value to duration type field then it is not working . Sometimes i am getting some 1970-01-01 date with the difference value added to that date. Please advise.

1 ACCEPTED SOLUTION

@RC Since I have used calculated value it is read-only be dafault you can use the same script in a before business rule as well. You just have to change the last line. 

 

instead of return dur ; use below line

current.<duration_field_name> = dur;

View solution in original post

5 REPLIES 5

suvro
Mega Sage
Mega Sage

You can use the calculated value of the duration field like below

find_real_file.png

 

find_real_file.png

RC19
Tera Contributor

Hi Suvro,

Thanks for the reply. The requirement can be fulfilled using string type field but the requirement here is use duration type field only so I wanted to know if the difference of two date/time fileds can be calculated in a duration type field or not. If yes, how ?

I have used duration type field only ....

@RC Since I have used calculated value it is read-only be dafault you can use the same script in a before business rule as well. You just have to change the last line. 

 

instead of return dur ; use below line

current.<duration_field_name> = dur;