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
Abi V 4Abi V 4 

Compare Current Month with Integer field inside For loop

String currentmonth = String.Valueof(Date.Today().Month());
for(test__c revn :revnlist){
if(revn.invoice_month__c.equals(currentmonth)){
revenuelist.add(revn);
               }
}
It is not entering into If condition.Here the invoice_month__cholds the values like 1,2,3.. and currentmonth values like 1,2,3..etc
Rohit Sharma 66Rohit Sharma 66
Try and use the sample cod ebelow:

Replace Account acc with revnlist

String currentmonth = String.Valueof(Date.Today().Month());
system.debug('***'+currentmonth);
List<Account> acc = [Select Id, Name, Site, NumberOfEmployees from Account]; // query record for the revnlist object
for(Account revn : acc){
if(revn.Site == currentmonth){
    system.debug('***Site'+revn.Site);
    // revenuelist.add(revn); create a new list and add value into that list
               }
    else{
        system.debug('***currentmonth'+currentmonth);
    }
}

Let me know if this helps you.
Abi V 4Abi V 4
I have already tried this but not entering into if condition at all. 
List<test__c> revenuelist= new List<test__c>();
  set<String> revsetmonths=new set<String>();
  List<test__c> revenuelistquery=[select master_customer_nbr__c,master_customer_name__c,customer_po_nbr__c,order_nbr__c,quick_look_id__c,invoice_quater__c,invoice_month__c from test__c where quick_look_id__c IN:qlkid];
      String currentmonth = String.Valueof(Date.Today().Month());
 
       for(test__c revn:revenuelistquery){
 
    
                   if(selectedreports =='Revenue YTD'){
                
                    revenuelist.add(revn);
                    }
                     
                    if(selectedreports =='Revenue MTD') {
                    system.debug('entermtdif###1');
                        if(revn.invoice_month__c == currentmonth){
                        system.debug('entermtdif###2');//not enetring into this loop 
                        revenuelist.add(revn);
                        
                        }
                    }
    }
Rohit Sharma 66Rohit Sharma 66
Please put the complete code here. I am not understand what u are getting in the qlkid in ur SOQL query. Also what u are getting in the selectedreports variable. Also user system.debug in ur code so that u can understand till which part of code u r getting the values.
Abi V 4Abi V 4
Code is huge lines.
qlkid is user object text fielsd and selectedreports is selectlist value from Vf page