I am running a batch class. I am providing query in string format. I am facing issue with using a filter criteria StartDate__c>=:System.today()
In a direct query, i could write something like
List<Contact> allContacts = [Select Id from Contact where StartDate__c>=:System.Today()];
But in start method of batch job, i am writing this
global Database.QueryLocator start(Database.BatchableContext BC){
String todayDate = System.today().format();
String queryString = 'Select Id from Contact where StartDate__c>='+todayDate;
return Database.getQueryLocator(queryString);
}
unfortunately, i am getting error - unexpected token: /
I believe the start date in string format is coming out to be 5/8/2021 and when it is concatenated to querystring, that / is causing issues. Anyway i can escape it?
Or for that matter, is there a better way to put that where clause for a date field while using String query?