When the duration field is calculated from date type fields using g_form.setValue() in a client script, the value is not saved on saving the form.
The probable cause of the issue is the existing problem - PRB1274011. According to the problem, using g_form.setValue() on a Duration field does not work correctly. However, after considering the priority and severity of the problem, it is closed as won't fix.
In order to resolve, please use Before Update business rule that uses "gs.dateDiff", and this will work as a workaround. Refer the below link for a sample script.