Skip to main content
I have 3  fields,start date ,week year count and week start ,i want to count all the week/Year based on start date.

 

for example start date is 12/01/2018,after 7 days the count will be 1/0,after next 7 days the count will be 2/0, after one year the count will be 0/1 based on start date 
1 answer
  1. Dec 1, 2018, 8:58 AM
    Hi Gopal,

     

    Triggers and Batch classes are not thee solution here. Because this result is time-dependent, you will be forced to schedule the code to run every single week. With time, this will expand more and more and consume more and more system resources - which is not something you want.

     

    A formula field, on the other hand, can calculate the value as the record is being read, so you do not need to schedule recalculations all the time.

     

    So let's create the Week and Year fields as formulas:

     

    Year: FLOOR((TODAY() - Date__c) / 365)

     

    Week: FLOOR(((TODAY() - Date__c) - (Year__c * 365)) / 7)
0/9000