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
DeptonDepton 

Age field avoiding weekends

Hi,

 

I am running crazy trying to calculate age since a custom date/time field gets populated. Avoiding weekends.

I thought I founded the formula but is giving me some errors.

 

Anyone has a trigger that counts the hours bases on a date/time field?. Avoiding weekends.

 

So it will count 24 hours from Monday to Friday.

Zero hours Saturday and Sunday!

 

Basically once I select Status A, I populate a custom date/time field with NOW(), and then I want the Age Status to tell me how many hours the field is with that status.

If I change the status I want the field to be Zero again....Avoiding weekends

 

Anyone had this issue before?

Thanks.:)

Scott_VSScott_VS

We developed a solution to this in our Case Flags app. Without giving away too much of the magic, we use the Business Hours class in Apex to exclude nights and weekends.