You need to sign in to do that
Don't have an account?
Victor19
SOQL Unexpected token error for Date field
Hi,
I am trying to build a SOQL query and my condition is when Intake date in object 1 is greater than Start date in object 2 and lesser than End date n Object, then I will be getting the id of the record. Please see my code below:
Object1 obj1 = trigger.new[0];
List<Object2> DateList = [Select id, Start_Date__c, End_Date__c FROM Object2 WHERE obj1.Intake_Date__c > Start_Date__c AND obj1.Intake_Date__c < End_Date__c];
Can someone please suggest a fix to my code?
Thanks!
I am trying to build a SOQL query and my condition is when Intake date in object 1 is greater than Start date in object 2 and lesser than End date n Object, then I will be getting the id of the record. Please see my code below:
Object1 obj1 = trigger.new[0];
List<Object2> DateList = [Select id, Start_Date__c, End_Date__c FROM Object2 WHERE obj1.Intake_Date__c > Start_Date__c AND obj1.Intake_Date__c < End_Date__c];
Can someone please suggest a fix to my code?
Thanks!
Object1 obj1 = trigger.new[0];
List<Object2> DateList = [Select id, Start_Date__c, End_Date__c FROM Object2 WHERE Start_Date__c < :obj1.Intake_Date__c AND End_Date__c > :obj1.Intake_Date__c];
-Glyn
All Answers
[SELECT Id, Start_Date__c, Obj1__r.IntakeDate__c FROM Object2 WHERE obj1__r.Intake_Date__c < Start_Date__c AND obj1__rIntake_Date__c < End_Date__c ]
There is a lookup relationship between both the objects. Object1 has a lookup to Object2 and Object1 is the standard Case Object.
I used your statement and it did not work!
Object1 obj1 = trigger.new[0];
List<Object2> DateList = [Select id, Start_Date__c, End_Date__c FROM Object2 WHERE Start_Date__c < :obj1.Intake_Date__c AND End_Date__c > :obj1.Intake_Date__c];
-Glyn