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
mamidi maheshmamidi mahesh 

how to add 1 to todaydate variable in query in batch apex

global class ClosePosEveryDay implements database.Batchable<sObject>{
 global database.QueryLocator start(database.BatchableContext bc){
    String query;
    date todayDate=date.today();
    System.debug('Today Date------------->'+todayDate);
    System.debug('System Date------------->'+System.today());
    query='select id,Status__c from position__c where Status__c=\'Closed\' and createdDate<=:todayDate'+'+1';
    System.debug('Query------------->'+query);
    return Database.getQueryLocator(query);
    }
    global void execute(database.BatchableContext bc, List<position__c> scope){
    System.debug('Scope------------->'+scope);
    for(position__c posRec:scope){
    posRec.Status__c='Closed';
   
    }
    Database.update(scope,false);
    }
    global void finish(database.BatchableContext bc){
    }
    }
in this above cod i want to add 1 to todayDate variable in that query only. this code throwing an error. pleas give me answer
kiran kumar 82kiran kumar 82
  query='select id,Status__c from position__c where Status__c=\'Closed\' and createdDate<=:todayDate+1';
or
date todayDate=date.today()+1;

 
Shaijan ThomasShaijan Thomas
date.today().AddDays(1));
Thanks
Shaijan
Shaijan ThomasShaijan Thomas
If it helps please make it best answer
mamidi maheshmamidi mahesh
i want to add integer number 1 to date type variable in soql query
mamidi maheshmamidi mahesh
this is not valid answer it does not workout, i want to add integer number 1 to date type variable todayDate in soql in apex code only.
Shaijan ThomasShaijan Thomas
As per you code todayDate + 1 Query; Uase Define todayDate=date.today().AddDays(1)), AND use in Query
else
 todayDate=date.today().AddDays(integer.valueof(<put integer string here>)))