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
Manish Kumar 23Manish Kumar 23 

SLA Time calculation for business hours from 10 :00 to 17: 00 and it should exclude sunday

Hi All,
I am using below formula to calculate SLA: It will take only working hours i.e from 10:00 to 19:00 , It will exculde Sunday . THis formula is working for all condition excet one: When I am giving  date and time before working hrs, the output SLA field is showing 9 hrs i.e worng it should show 0 hrs.
Refer below example
Date_2__c  as 12/25/2018 7:00  and Date_1__c 12/25/2018 9:00 
SLA calculation -9 Hrs( Which is wrong it should give 0 as output)
Can you please help me in resolving this issue

Below Formula I am using for calculation of SLA 
9 *( (6*FLOOR(( DATEVALUE( IF(ISNULL(Date_1__c), NOW(), Date_1__c) ) -DATE(1996,01,01))/7) 
        +
        MIN(6, 
        MOD(DATEVALUE( IF(ISNULL(Date_1__c), NOW(), Date_1__c) )-DATE(1996,01,01), 7) +
        MIN(1, 24/ 9 *(MOD( IF(ISNULL(Date_1__c), NOW(), Date_1__c) -DATETIMEVALUE('1996-01-01 04:30:00'), 1)))
        ))
        -
        (6*FLOOR((DATEVALUE( Date_2__c + MAX(DATETIMEVALUE(TEXT(DATEVALUE(Date_2__c)) & " 04:30:00") - Date_2__c,0) )-DATE(1996,01,01))/7) +
        MIN(6, 
        MOD(DATEVALUE( Date_2__c + MAX(DATETIMEVALUE(TEXT(DATEVALUE(Date_2__c)) & " 04:30:00") - Date_2__c,0) )-DATE(1996,01,01), 7) +
        MIN(1, 24/ 9 *(MOD( Date_2__c + MAX(DATETIMEVALUE(TEXT(DATEVALUE(Date_2__c)) & " 04:30:00") - Date_2__c,0) -DATETIMEVALUE('1996-01-01 04:30:00'), 1)))))
         )