+ Start a Discussion
Mathew ArcillaMathew Arcilla 

Way to count days while a condition is true?

I'm trying to build out a field that counts days while a condition is true. It's intended to count tenure while the customer is in an active membership.

We do have variables for the start date and end date of the membership which counts tenure of that specific membership, but we can't just use that because if the customer discontinues their membership and picks up a new membership at a later time, they'll start at the tenure they previously had. Another issue is they can have multiple memberships active at the same time so it can't be a tally of ALL membership tenures. 

Essentially I need it to be this psuedocode:

AT 12:00AM, IF ActiveMembership >0 THEN TenureDayCounter=TenureDayCounter+1.

Does this make sense? Hoping for some pointers here. 

Thanks in advance for your help. 

ANUTEJANUTEJ (Salesforce Developers) 
Hi Mathew,

I tried checking this scenario of implementation but I was not able to find the same one but there are few implementations I found that you could use for reference below are the links for them:

>> https://trailblazers.salesforce.com/answers?id=90630000000hPnmAAE

>> https://trailblazers.salesforce.com/answers?id=90630000000gocjAAA

I hope this helps and in case if this comes in handy can you please choose this as the best answer so that it can be used by others in the future.

Abhishek Sharma 36Abhishek Sharma 36
Use a batch class that will run daily and update that counter. Process Builder/Trigger/workflow/formula field etc wont help here.