You need to sign in to do that
Don't have an account?
mamidi 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){
}
}
i know we can add 1 before writing query. but it should be written in query only.please give me valid answer for this. is it possible or not to add 1 to date type variable in soql query. please tell me.
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){
}
}
i know we can add 1 before writing query. but it should be written in query only.please give me valid answer for this. is it possible or not to add 1 to date type variable in soql query. please tell me.
Frédéric Trébuchet
Hi,
Fred