function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Stefano AmentaStefano Amenta 

Business hours for weekdays and weekends

Hi,

Recently I have been using this formula to calculate business hours for 5 days a week, for 9 hours, from 9am to 6pm China time.

The problem is that now the team will also start to work on Saturday and Sunday, but on a slightly different time: from 10am to 9pm China (11 hours).

How could I incorporate the new time inside the below formula? So the formula should consider two different timeframes: 9am to 6pm (weekdays) and 10am to 9pm (Saturday and Sunday).

How could I achieve that?
 
9 * (
   ( 5 * FLOOR( ( DATEVALUE(Now()) - DATE( 1900, 1, 8) ) / 7) +
    MIN(5, 
     MOD( DATEVALUE(Now()) - DATE( 1900, 1, 8), 7) +
     MIN( 1, 24 / 8 * ( MOD(Now() - DATETIMEVALUE( '1900-01-08 01:00:00' ), 1 ) ) )
    ) 
   )
 -
   ( 5 * FLOOR( ( DATEVALUE([Case].New_status_time_track_ALL__c) - DATE( 1900, 1, 8) ) / 7) +
     MIN( 5,
      MOD( DATEVALUE([Case].New_status_time_track_ALL__c) - DATE( 1996, 1, 1), 7 ) +
      MIN( 1, 24 / 8 * ( MOD([Case].New_status_time_track_ALL__c - DATETIMEVALUE( '1900-01-08 01:00:00' ), 1) ) )
    )
   ) 
  )