I have a silly problem, when I pass Date from lightning input (type=date) i pass it as a string, and when i creating a query with this paramiter i recived error like below
value of filter criterion for field 'StartDate' mu…of type date and should not be enclosed in quotes
So when i converted to Date type using Date.parse i recived error code
Invalid date: 2020-03-12
But when i convert String to Date using Date.valueOf
no viable alternative at character ''
here is my code
if(!key.equals(START_DATE)) {
query += key + ' = ' + QUOTES + String.valueOf(inputMap.get(key)) + QUOTES + ' AND ';
}else{
startDate = Date.valueOf(inputMap.get(key));
query += key + ' = ' +startDate+ ' AND ';
}
And here's an example of the generated SOQL:
SELECT Id, AccountId ,CustomerSigned.Name, Name, Status, ContractNumber, Account.Name, Account.BillingCity, Education_Level__c, isActive__c, StartDate, ActivatedDate, EndDate, Category__c, Performance_Evaluation__c
FROM Contract
WHERE Account.Name = 'TestName' AND StartDate = 2020-03-12 00:00:00