You need to sign in to do that
Don't have an account?
Afzaal Hassan
Database query syntax error
Hello
I have written a scheduled apex batch job which compiles fine. However, when I ran the job, the queue (in the UI) says the following error:
"First error: value of filter criterion for field 'Client_Released_Date__c' must be of type dateTime and should not be enclosed in quotes". Below is my start method for the scheduled batch apex:
global Database.QueryLocator start(Database.BatchableContext BC) {
Datetime clientReleasedDate = Datetime.now().addHours(-1);
return Database.getQueryLocator(
'SELECT Id, Client_Released__c, Client_Number__c, Client_Release_Date__c, ' +
'Email_Sent__c FROM Account ' +
'WHERE Email_Sent__c = true AND Client_Released__c = true AND Client_Release_Date__c>= \''+ clientReleasedDate +'\''
);
}
I check the client_released_date__c and I confirmed that it is a datetime field. So the datatype matches. I am suspecting I have my SOQL query syntax wrong. Perhaps I am escaping the quotes when I dont need to. Can someone please check and correct my method/syntax for the query locator?
Thanks
I have written a scheduled apex batch job which compiles fine. However, when I ran the job, the queue (in the UI) says the following error:
"First error: value of filter criterion for field 'Client_Released_Date__c' must be of type dateTime and should not be enclosed in quotes". Below is my start method for the scheduled batch apex:
global Database.QueryLocator start(Database.BatchableContext BC) {
Datetime clientReleasedDate = Datetime.now().addHours(-1);
return Database.getQueryLocator(
'SELECT Id, Client_Released__c, Client_Number__c, Client_Release_Date__c, ' +
'Email_Sent__c FROM Account ' +
'WHERE Email_Sent__c = true AND Client_Released__c = true AND Client_Release_Date__c>= \''+ clientReleasedDate +'\''
);
}
I check the client_released_date__c and I confirmed that it is a datetime field. So the datatype matches. I am suspecting I have my SOQL query syntax wrong. Perhaps I am escaping the quotes when I dont need to. Can someone please check and correct my method/syntax for the query locator?
Thanks
Raj Vakati
Try this
Raj Vakati
Or you can do it as below