Adding two duration fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2023 12:20 PM
I have two duration fields and i want to add the values in those two duration fields and then display the result in hours. How can i achieve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2023 12:37 PM
Hi @hameetkaur ,
I imagine what do you want to say is, you have for example "Duration 1" field and "Duration 2" field, and you want to have for example "Date Time finish 1" and "Date Time finish 2". Correct me if I'm wrong, you have another field to consider the duration start counting time for example the "created on" field and sum the duration? Can you provide more context about what is you final goal to provide a more help, at the end if what I think is correct you can only create a Business Rule and execute from you reference date and sum the duration of you field to get a final stimated date.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2023 12:48 PM
I have 2 fields say 'Duration 1' field and 'Duration 2' field and i want to add both the two fields and display the result in the hour format.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2023 01:00 PM
Hi @hameetkaur
You need to use getGlideObject().getNumericValue()*0.001/3600 to convert it to hours.
Did test for one record in background script as below.
var inci=new GlideRecord('incident');
inci.addQuery('sys_id','9c573169c611228700193229fff72400');
inci.query();
if(inci.next())
{
var dur = inci.calendar_duration.getGlideObject().getNumericValue()*0.001/3600;
gs.print(dur);
}
Result is
11799.3125
Apply the same logic of getGlideObject().getNumericValue()*0.001/3600 to convert duration value to hours and then a simple parseInt() or parseFloat() to add the total in hours.