I have a requirement where I have to write a query with a condition that the Last Modified date should be between 30 and 60 days and this should be configurable by user. I have created a custom setting for this to make it configurable but couldn't find anything to check date between 30 and 60 days. Is there any formula which can help me?

2 Answers 2


Instead of using custom setting, you can create two new "Custom Lables" and can provide values of 30 & 60 to each. Then use the below lines to retrieve the lables values and put them in your query.

String x= System.Label.Custom_Label_Name; //Retrives custom label value
Integer y = Integer.valueOf(x); //Converts custom label value from string to Integer

Hope this helps you!



Posting the code snippet where I did this through custom setting

 Integer DayCount=Integer.valueof(TargetGlobalMapping__c.getValues('DataRetentionCaseUpdate').Num_Value_1__c);
     if(DayCount>30 && DayCount<60){
        // here my query goes to fetch the record for specific conditions

You must log in to answer this question.