HOPCalcDuration

Calculates the duration, in seconds, between two dates and times based on an hours of operations (HOP) schedule. The hours of operation calculation is based on the hours of operation schedule, which is set in the application configuration.

Syntax

HOPCalcDuration(hopIdOrName, utcStart, utcEnd)

Enabled For

For a description of the business object categories, see Notes on "Enabled For".

Business Object Category Yes/No
Business Rules: Before-Save Rules Yes
Business Rules: Calculation Rules (After Save, with or without Also Recalculate on Load) Yes
Business Rules: Calculation Rules (Before Save or Always, without Also Recalculate On Load) Yes
Business Rules: Calculation Rules (Before Save or Always, with Recalculate On Load) Yes
Business Rules: Editing Rules Yes1
Business Rules: Initialization Rules Yes
Business Rules: Read Only Rules No
Business Rules: Required Rules Yes1
Business Rules: Validation Rules Yes
Client Expressions No
Object Permissions No
Services Yes
LDAP Yes
Mobile Yes
Quick Actions (except UI Quick Actions) Yes
UI Quick Actions No
Reports Yes
Search/Dashboard without field references Yes
Search/Dashboard with field references No
1. Except when this field appears on a form or is triggered by such a field.

Parameters

Parameter Description

hopIdOrName

The hours of operation schedule name as defined. See Setting Up Hours of Operation.

utcStart

The start date and time in DateTime value.

utcEnd

The end date and time in DateTime value.

Return Value

Number value.

Example

$(HOPCalcDuration("Weekly HOP", Today(), Tomorrow()) / 3600)

 

The example above returns the total number of working hours for today. It ignores any hours outside of the hours of operation schedule. If the schedule called Weekly HOP sets the working hours as 8am to 5pm, this example returns 9.

This function returns the value in seconds.  To return the value in minutes, divide the result by 60.  To return the value in hours, divide the result by 3600.