Notifications

117 views

Description

How to calculate the incident duration field?

Release or Environment

Any

Resolution

There are two Duration fields on Incident which are "Business duration" and "Calendar duration". Both Duration fields are calculated by the OOB business rule "mark_closed" on the incident table. 

These are the following code in the business rule: 

if (dataChange || current.business_duration.nil()) 
current.business_duration = gs.calDateDiff(opened, closed, false); 

if (dataChange || current.calendar_duration.nil()) 
current.calendar_duration = gs.dateDiff(opened, closed, false); 

Both Duration fields are actually calculated based on incident opened time and incident closed time only.

It is clear that duration for incident is calculated based on incident opened time and incident closed time only. It is calculated regardless what states incident has ever been set to. The duration of incident is simply the time difference between incident opened time and incident closed time. Putting incident in "Awaiting User Info" state would definitely affect the duration for the incident because the pause period would be counted into the duration in this case.

Example

Incident create time: 3pm
Put incident into Awaiting User Info time: 4pm
Change incident state back to Active: 5pm
Close incident: 6pm

 

For this example, the duration of the incident would be 3 hours because it is created at 3pm and is closed at 6pm.

 

Additional Information

https://docs.servicenow.com/bundle/madrid-platform-administration/page/administer/time/concept/c_ResolveTime.html

Article Information

Last Updated:2019-08-25 21:39:15
Published:2019-08-26