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
SyeawarSyeawar 

can someone help me getting case age in hours and that would not include weekends please

can someone help me getting case age in hours and that would not include weekends please
PriyaPriya (Salesforce Developers) 
If you require information that can be displayed on the case record itself you can create a complex formula. An example of what a formula for CST and standard M-F business hours (these business hours need to be configured under Setup | Company Profile | Business Hours)  is below:
 
IF(DATEVALUE(CreatedDate) = DATEVALUE(ClosedDate),  
(ClosedDate - CreatedDate) * 24,  
((CASE(MOD(DATEVALUE(CreatedDate) - DATE(1985,6,24),7),  
0 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,2,2,3,3,4,4,5,5,5,6,5,1),  
1 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,2,2,3,3,4,4,4,5,4,6,5,1),  
2 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,2,2,3,3,3,4,3,5,4,6,5,1),  
3 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,2,2,2,3,2,4,3,5,4,6,5,1),  
4 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,1,2,1,3,2,4,3,5,4,6,5,1),  
5 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,0,2,1,3,2,4,3,5,4,6,5,0),  
6 , CASE( MOD(DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate) ,7),1,1,2,2,3,3,4,4,5,5,6,5,0),  
999)  
+ (FLOOR((DATEVALUE(ClosedDate) - DATEVALUE(CreatedDate))/7)*5)  
- 2) * 9)  
+  
MAX((  
DATETIMEVALUE(TEXT(YEAR(DATEVALUE(CreatedDate))) & "-" & TEXT(MONTH(DATEVALUE(CreatedDate))) & "-" & TEXT(DAY(DATEVALUE(CreatedDate))) & " 01:00:00am") - CreatedDate + 1) * 24, 0))  
+  
MAX((ClosedDate -  
DATETIMEVALUE(TEXT(YEAR(DATEVALUE(ClosedDate))) & "-" & TEXT(MONTH(DATEVALUE(ClosedDate))) & "-" & TEXT(DAY(DATEVALUE(ClosedDate))) & " 16:00:00")) * 24, 0)
Reference :- Calculate Case age based on working business hours (https://help.salesforce.com/s/articleView?id=000329632&type=1)

Kindly mark it as the best answer if it works for you.

 

Thanks & Regards,

Priya Ranjan


 
SyeawarSyeawar
Thank you soo much Priya 
one more question how to get the case age based on last modified in hours 
 
SyeawarSyeawar
it did not work 
prabhakar Thummojiprabhakar Thummoji

Hi Syeawar,

You can try below formula for your requirment case age based on last modified in hours,It may help you to resolve your issue.
Formula:
Case Age in Hours - IF( IsClosed , (ClosedDate - CreatedDate) *24, (NOW() - CreatedDate ) *24)
You can also refer the below link,if needed and for reference..
https://help.salesforce.com/s/articleView?id=000341512&type=1

Please mark it as best answer if its helps you to resolve your requirement.
Regards,
Prabhakar.T

SyeawarSyeawar
that one is correct but that one would include weekends 
here I have this formula that gets the day but i want to get the hour somehow I want to convert the day to hours 
TEXT( 

CASE(MOD( DATEVALUE(LastModifiedDate) - DATE(1985,6,24),7),
0 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,2,2,3,3,4,4,5,5,5,6,5,1),
1 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,2,2,3,3,4,4,4,5,4,6,5,1),
2 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,2,2,3,3,3,4,3,5,4,6,5,1),
3 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,2,2,2,3,2,4,3,5,4,6,5,1),
4 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,1,2,1,3,2,4,3,5,4,6,5,1),
5 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,0,2,1,3,2,4,3,5,4,6,5,0),
6 , CASE( MOD( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) ,7),1,1,2,2,3,3,4,4,5,5,6,5,0),
999)
+
(FLOOR(( DATEVALUE(NOW ()) - DATEVALUE(LastModifiedDate) )/7)*5)
)& " Day"

I did get this answer https://jayakrishnasfdc.wordpress.com/2020/04/20/calculate-age-of-recordformula-field-to-exclude-saturday-and-sunday/ 
but this one give me syntax error can you please help and fix the error