I am writing an Batch apex where I need to query the records which are created today(System date).
I created one field name Created_Date_Formatted__c
which just gives me only date from CreateDate
field.
In my start(Database.BatchableContext BC) method, I am passing my query as string
query ='SELECT id,name FROM sObject__c WHERE Created_Date_Formatted__c = '+ String.valueOf(System.now());
I have records which has created_Date_format__c as today, When I am querying the records in query editor without any where clause it gives me all the records
But when I copy the date(red marked) and put the where clauses it does not work
I have tried putting date in different format but it doesn't work. I would really appreciate if anyone can help me. Please let me know if anything else is also required from my side. I will update the thread. Thanks
Created_Date_Formatted__c FROM sobject__c WHERE Created_Date_Formatted__c = '2017-08-09' ^ ERROR at Row:1:Column:65 value of filter criterion for field 'Created_Date_Formatted__c' must be of type date and should not be enclosed in quotes