Loading

Calculate Case age based on working business hours

Julkaisupäivä: Jun 24, 2026
Kuvaus

To track the time an agent spends on a Case using your organization's configured business hours, you can request enablement of the 'Enable Case Duration/Age in Business Hours' feature through Salesforce Support. Once enabled, this adds a 'Business Hours Age' field to the Case object that can be used in reports.
Note: The 'Business Hours Age' field is not available in reports if the organization's business hours are set to 24/7.

Ratkaisu

 

Recommended Solution: Enable the Business Hours Age Feature

The recommended approach for tracking Case age based on business hours is to request enablement of the 'Enable Case Duration/Age in Business Hours' feature. Once enabled, a 'Business Hours Age' field becomes available on the Case object and can be included in your Salesforce reports without requiring a custom formula.
To request this feature, contact Salesforce Support and ask to enable Case Duration/Age in Business Hours for your org.
Note: This field only works in reports. It is not available for display directly on the Case record layout. If you need to display business hours age on the Case record itself, see the custom formula option below.

Alternative: Custom Formula for Case Age Calculation

If you need to display business hours age directly on the Case record, you can create a custom formula field. The example below calculates Case age for CST time zone, Monday–Friday standard business hours (configured under Setup > Company Profile > Business Hours).

  • Formula :
    IF(DATEVALUE(CreatedDate) = DATEVALUE(ClosedDate),  
    (ClosedDate - CreatedDate) * 24,  
    ((CASE(MOD(DATEVALUE(CreatedDate) - DATE(1985,6,24),7),  
    0 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,2,2,3,3,4,4,5,5,5,6,5,1),  
    1 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,2,2,3,3,4,4,4,5,4,6,5,1),  
    2 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,2,2,3,3,3,4,3,5,4,6,5,1),  
    3 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,2,2,2,3,2,4,3,5,4,6,5,1),  
    4 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,1,2,1,3,2,4,3,5,4,6,5,1),  
    5 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,0,2,1,3,2,4,3,5,4,6,5,0),  
    6 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,1,2,2,3,3,4,4,5,5,6,5,0),  
    999)  
    + (FLOOR((DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate))/7)*5)  
    - 2) * 9)  
    +  
    MAX((  
    DATETIMEVALUE(TEXT(YEAR(DATEVALUE(CreatedDate))) & "-" & TEXT(MONTH(DATEVALUE(CreatedDate))) & "-" & TEXT(DAY(DATEVALUE(CreatedDate))) & " 01:00:00am") - CreatedDate + 1) * 24, 0))  
    +  
    MAX((ClosedDate -  
    DATETIMEVALUE(TEXT(YEAR(DATEVALUE(ClosedDate))) & "-" & TEXT(MONTH(DATEVALUE(ClosedDate))) & "-" & TEXT(DAY(DATEVALUE(ClosedDate))) & " 16:00:00")) * 24, 0)

Important notes before using this formula:

  • This is a reference example only. Do not copy and paste this formula directly into your environment.
  • Different time zones and business hours configurations will produce different results and may cause the formula to behave incorrectly.
  • This formula may not work correctly on List Views or Reports — for reports, use the 'Business Hours Age' field instead.

The formula logic accounts for: open and close time boundaries for each business day, exclusion of weekends, and handling of cases opened and closed on the same day.
      

AppExchange Solutions

For additional options, explore third-party solutions for business hours case age calculation on the Salesforce AppExchange.

 

Knowledge-artikkelin numero

000385836

 
Ladataan
Salesforce Help | Article