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
prasanth kumarprasanth kumar 

error in batch apex query.

        return database.getquerylocator('select id,name__c,name__c,Project_Name__c from customerstatus__c where End_date__c  =: Date.today().addDays(-2)');   

i am using this in batch apex start method.  i am getting error at this line at  where condition.     FATAL_ERROR System.QueryException: unexpected token: 'where'  
Abhi_TripathiAbhi_Tripathi
You can try 

Date dte = Date.today().addDays(-2);
 return database.getquerylocator('select id,name__c,name__c,Project_Name__c from customerstatus__c where End_date__c  =: dte ;   
prasanth kumarprasanth kumar
love u dude.....................       Thank you very much.   
prasanth kumarprasanth kumar
hi, now i am getting unexpceted token where  error.   please solve this. 

Date dte = Date.today().addDays(-2);
      
         String Name ='dell ';
       String ActName ='Activity ';
       
return database.getquerylocator('select id,name__c,name__c,Project_Name__c from customerstatus__c where End_date__c staus__c !=\''+Name+'\' and type__c=\''+ActName+'\' where actual_End_date__c =: dte '
 
Abhi_TripathiAbhi_Tripathi
Please check the SOQL that you have written, it has 2 where , , you cannot do that in an SOQL

For basics of writing batch, you can go to this link
http://cloudyabhi.blogspot.in/2014/07/basics-of-apex-batch-class-in-salesforce.html