Created
September 14, 2017 15:36
-
-
Save ijason/55976c9b4458e614217eaecbdaa044b1 to your computer and use it in GitHub Desktop.
Salesforce formula to find the number of hours between two date/times excluding weekends.
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
ROUND(24*( | |
(5*FLOOR((TODAY()-DATE(1996,01,01))/7) + | |
MIN(5, | |
MOD(TODAY()-DATE(1996,01,01), 7) + | |
MIN(1, (MOD(NOW()-DATETIMEVALUE('1996-01-01 00:00:00'), 1))) | |
)) | |
- | |
(5*FLOOR((DATEVALUE(NULLVALUE(Last_Activity_Date__c, CreatedDate))-DATE(1996,01,01))/7) + | |
MIN(5, | |
MOD(DATEVALUE(NULLVALUE(Last_Activity_Date__c, CreatedDate))-DATE(1996,01,01), 7) + | |
MIN(1, (MOD(NULLVALUE(Last_Activity_Date__c, CreatedDate)-DATETIMEVALUE('1996-01-01 00:00:00'), 1))) | |
)) | |
), 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, It is not working. for example, I have two date-time fields start date and end date. So, where do I replace that field in your code? Please let me know as soon as possible.
Thanks in advance.