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 integer number 1 to date type variable todayDate in soql query(query='select id,Status__c from position__c where Status__c=\'Closed\' and createdDate<=:(todayDate)+1';)

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){
    }
    }
please give me valid answer for this.
Jerome LusinchiJerome Lusinchi
Hi mamidi,

Try calculating you date before your query : 

date MyDate=date.today();
MyDate = todayDate.addDays(1);

and then use MyDate in your query.

regards,
jerome
mamidi maheshmamidi mahesh
it should be writen in query only. is it not possible
Frédéric TrébuchetFrédéric Trébuchet
Hi,
select id,Status__c from position__c where Status__c=\'Closed\' and createdDate <= TOMORROW
Hope this helps,
Fred