I think you are comparing datetime field (Created date) with date field (firstrrespondeddate).
So, use following soql query:
select id, campaignid, FirstRespondedDate, status,hasresponded,Campaign.StartDate,Campaign.Type from CampaignMember where ContactId=:opportunity.Principal_Owner__c and hasresponded=true and FirstRespondeddate <: Date.valueOf(opportunity.createdDate) and FirstRespondedDate>:Opportunity.closeDate
Make sure that you compare between (Date with date) or (DateTime with DateTime). If you compare Date with DateTime, then you can convert that DateTime field to Date as Date.valueOf(fieldName) before query and then use the value in query for comparison.
If this post solves your problem, kindly mark it as solution.
Hi Vari,
I think you are comparing datetime field (Created date) with date field (firstrrespondeddate).
So, use following soql query:
Createddate is a datetime field. You need to convert it to Date before it can be compared against a date field.
DateTime dt = opportunity.createdDate;
Date opdate = date.newinstance(dt.year(), dt.month(), dt.day());
Now in the query, use "First Responded date <: opdate" instead of "FirstRespondeddate <: opportunity.createdDate"
That should solve your problem.
Hi Vari,
Make sure that you compare between (Date with date) or (DateTime with DateTime). If you compare Date with DateTime, then you can convert that DateTime field to Date as Date.valueOf(fieldName) before query and then use the value in query for comparison.
If this post solves your problem, kindly mark it as solution.
Thanks