How to subtract to dates and the populate the outcome in a Duration type field

Alon Grod
Tera Expert

Hi,

I have the field updated and the field date_move_to_pending both of type Date/Time. I want to subtract date_move_to_pending from updated and then populate the outcome in the field Resolve time of type Duration.

How can I achieve that?

1 REPLY 1

shloke04
Kilo Patron

Hi @Alon Grod ,

 

Please write a Before Update BR on your required table and use the script shared below:

 

var diff = GlideDateTime.subtract(current.date_move_to_pending.getDisplayValue(), current.sys_updated_on.getDisplayValue());
var diffString = diff.getDisplayValue();

current.resolvedFieldName = diffString;

Please adjust field names as required in above script.

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke