Here I am doing an aggregate SOQL
List<AggregateResult> ListName = [select SUM(Field1__c), SUM(Field2__c),
from CustomObject__c
where Object2__r.Id In :List2
AND ( createdDate>=: StartDateQuarter
AND createdDate<=: EndDateQuarter )
GROUP BY Object2__r.Name, Object2__r.Id ];
This is where I am determining the dates.
List<Period> LastDates = [Select type, StartDate, EndDate From Period WHERE type = 'Quarter' AND StartDate = LAST_N_QUARTERS:4 LIMIT 1];
Datetime StartDateQuarterLast = LastDates[0].StartDate;
Datetime EndDateQuarterLast = LastDates[0].EndDate;
This query is working when I am removing the DATE part. NOT working with the DATE filter.
StartDateQuarter and EndDateQuarter are getting values. I have checked that.
Is there any syntactical error?