calculate time in state based on business hours

Chris150
Tera Guru

Hello,

Were trying to find a metric that measures time in state.   We partially accomplished this by using the OOB "Incident State Duration" metric.

One thing that we do not like about it is that the clock/calendar it uses runs 24/7.

How do we tell it to use our business calendar as defined in System Policy, SLA, Calendars?

1 ACCEPTED SOLUTION

Dan -- I recently put in an enhancement request to allow a metric duration calculation to be linked to a schedule or calendar.



Our business case was for all metrics to be dependent on our calendar that is based on our business hours, so I chose to link all metric duration calculations to our calendar by changing the OOTB calculation from dateDiff to calDateDiff.


View solution in original post

8 REPLIES 8

Padmanabam Tiru
ServiceNow Employee
ServiceNow Employee

Hi Chris,




There is a field called as Business Duration in Incident_metric database view which actually calculates the business durations (8 hrs a day, eliminating weekends and public holidays), did you tried using that..



If you still want to explicitly load a schedule whichever you wish, then you have to use Script for calculating it. Following link gives you more details about loading schedule and calculating duration between two dates.



https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_re...


dd28
Kilo Explorer

Hi Chris,



Did you resolve your issue? I have the exact same requirement - Need to calculate Business Hours Duration on the State field.



I do not have 2 date fields to compare.



Instead, I have a Metric Definition running a Field Value Calculation on the State field, which currently counts non-business hours. How can I apply the business schedule to this Metric Definition?



Many thanks,



Dan


Dan -- I recently put in an enhancement request to allow a metric duration calculation to be linked to a schedule or calendar.



Our business case was for all metrics to be dependent on our calendar that is based on our business hours, so I chose to link all metric duration calculations to our calendar by changing the OOTB calculation from dateDiff to calDateDiff.


Thanks Jason