-
Hours between two date time formula showing negative values in Salesforce
I have written a formula to calculate the difference between two Date/Time fields,
Please find the formula`ROUND(24*(
(5*FLOOR((DATEVALUE(First_Response__c)-DATE(1996,01,01))/7) +
MIN(5,
MOD(DATEVALUE(First_Response__c)-DATE(1996,01,01), 7) +
MIN(1, 24/24*(MOD(First_Response__c-DATETIMEVALUE('1996-01-01 12:00:00'), 1)))
))
-
(5*FLOOR((DATEVALUE(CreatedDate)-DATE(1996,01,01))/7) +
MIN(5,
MOD(DATEVALUE(CreatedDate)-DATE(1996,01,01), 7) +
MIN(1, 24/24*(MOD(CreatedDate-DATETIMEVALUE('1996-01-01 12:00:00'), 1)))
))
), 2)Here I have a case whose created date is 12/12/2016 2:16AM and Firstresponse date is 12/12/2016 10:54 AM now the case response hour formula field shows me the difference between the above as -15.37 .
I tried to calculate the difference between two date Time for 24 hours not for a business hours, I only want to exclude weekends,
The hour calculation should be from 12:00 AM today to 11:59 PM the next day.
Please advise
Log In to reply.
Popular Salesforce Blogs

Learn About Permission Sets in Salesforce | Salesforce Security Guide
Permissions set and Profiles in Salesforce to limit what people may access, view, and do in their Salesforce org. The permission set resembles that of…

Influence of Salesforce on Non-Profit Organizations
Regardless of whether you are relieving kids, helping the old, sparing the earth or battling neediness, your nonprofit organization faces one major predicament. The difficulties…

Salesforce Service Cloud: Streamlining Customer Service Operations
Today's fiercely competitive business environment makes offering outstanding customer service more than simply a choice—it's a requirement. Customers now demand individualized, prompt, and effective service,…
Popular Salesforce Videos
Salesforce Marketing Cloud Connect: Subscriber Key Migration
We demo how leveraging a subscriber key migration to remove duplicate subscribers from Sales or Service Cloud in Marketing Cloud while minimizing data loss. Explore…
Einstein Opportunity Scoring For Everyone | Salesforce
Let artificial intelligence help you and your sales team focus on the right opportunities and close more deals. See how Einstein Opportunity Scoring makes it…
GS DevOps Mate: Your Free Flexible Toolkit for Faster & Smoother Salesforce Deployments
Our webinar about GS DevOps Mate: A free, open-source, CI/CD platform agnostic toolkit! Our host is Rohan Gore a Technical Architect here at Groundswell who…