Created
May 25, 2019 16:45
-
-
Save surajp/a8e5386cf6bf5fe2766d7e0a0484bccd to your computer and use it in GitHub Desktop.
Calculate Business Hours between 2 given date times in Salesforce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FLOOR((suraj__Actual_End_Date__c - suraj__Actual_Start_Date__c)/7)*5*9 + | |
MIN(5,FLOOR(MOD((suraj__Actual_End_Date__c - suraj__Actual_Start_Date__c),7)))*9+ | |
IF((TIMEVALUE(suraj__Actual_End_Date__c)-TIMEVALUE("12:00:00.00"))/(3600*1000)>16,0,MIN(9,(TIMEVALUE(suraj__Actual_End_Date__c)-TIMEVALUE("12:00:00.00"))/(3600*1000))) - IF((TIMEVALUE(suraj__Actual_Start_Date__c)-TIMEVALUE("12:00:00.00"))/(3600*1000)>16,0,MIN(9,(TIMEVALUE(suraj__Actual_Start_Date__c)-TIMEVALUE("12:00:00.00"))/(3600*1000))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assumes business hours of 8 am to 5 pm