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 

Formula for calculating case age excluding weekends and get age in hours

Hello there so below I did get the ageing days but i want to get hours too can someone help please
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"
mukesh guptamukesh gupta
Hi Syeawar,

Please follow below url that's will help for your solution

https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A80WOSAZ

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
SwethaSwetha (Salesforce Developers) 
HI Syeawar,
Does https://jayakrishnasfdc.wordpress.com/2020/04/20/calculate-age-of-recordformula-field-to-exclude-saturday-and-sunday/ help?

Apex approach: https://salesforce.stackexchange.com/questions/49111/formula-for-calculating-case-age-excluding-weekends-and-holidays

Thanks
SyeawarSyeawar
Thank you Swetha but there is a syntax error is there a way to fix the error and let me know please 
TEXT( ((DATEVALUE(NOW()) – DATEVALUE(CreatedDate))) – (CASE(MOD( DATEVALUE(CreatedDate)- DATE(1900, 1, 7),7),
0 , CASE( MOD( DATEVALUE(NOW()) – DATEVALUE(CreatedDate), 7),1,0,2,0,3,0,4,0,5,1,6,2,0),
1 , CASE( MOD( DATEVALUE(NOW()) – DATEVALUE(CreatedDate), 7),0,0,1,0,2,0,3,0,4,0,5,2,2),
2 , CASE( MOD( DATEVALUE(NOW()) – DATEVALUE(CreatedDate), 7),0,0,1,0,2,0,3,1,2),
3 , CASE( MOD( DATEVALUE(NOW()) – DATEVALUE(CreatedDate), 7),0,0,1,0,2,1,2),
4 , CASE( MOD( DATEVALUE(NOW()) – DATEVALUE(CreatedDate), 7),0,0,1,1,2),
5 , CASE( MOD( DATEVALUE(NOW()) – DATEVALUE(CreatedDate), 7),0,1,2),
6 , CASE( MOD( DATEVALUE(NOW()) – DATEVALUE(CreatedDate), 7),6,2,1),
999)
+
(FLOOR(( DATEVALUE(NOW()) – DATEVALUE(CreatedDate) )/7)*2)) ) & ” Days ” & TEXT( ROUND(MOD((NOW()- CreatedDate)*24,24),0) ) & ” Hrs “)
SyeawarSyeawar
here I came up with this but i get error can someone help and fix the error
Here is the formula in case want to help :)
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)
+
TEXT( FLOOR( MOD( ( NOW()  -  LastModifiedDate ) * 24, 24 ) ) )) & " hours "
Salesforce TechieSalesforce Techie
refer- https://thesalesforcetutorial.blogspot.com/2022/04/case-age-calculation-approaches.html
SyeawarSyeawar
Thanks Techie That gets me the days not hours I am trying to find the hours of ageing case can you please help with that 
Finley ColinFinley Colin
I need to create a formula field or apex method for calculating case age (from CreatedDate to now) excluding weekends and holidays (as defined in the case's business hours).
Is it possible with a formula field? If not, how difficult is this to do in apex?
https://knifeplatoon.com/