I am running the below code
List<AggregateResult> lstWO = [select Id, AccountId, MAX(Completed_Date__c) CompletedDate from WorkOrder WHERE Order__c IN (Select Id from Order WHERE AccountId = 'XXXXXXXXXXXXXXX' AND Status = 'Activated') AND Status = 'Completed' group by AccountId, Id];
// The above query will return a list of CompletedDate. The aim here is to compare the completed dates and output the most recent dates among those dates
List<compareDates> wo = new List<compareDates>();
for(AggregateResult w: lstWO) {
wo.add(new compareDates((String)w.get('Id'),(Date)w.get('CompletedDate')));
}
system.debug('wo' + wo.size());
public class compareDates implements Comparable {
public Id woId;
public date woDate;
public compareDates(String i, date n) {
woId = i;
woDate = n;
}
public Integer compareTo(Object compareTo) {
compareDates comparable = (compareDates)compareTo;
if (woDate > comparable.woDate) return 1;
return 0;
}
}
I have a list of dates . From this list goal is to pick up most recent dates, by comparing among each other. So the output will be "2019-05-29","2019-05-29", "2019-03-27",
"2019-05-13"
"2019-05-29"
"2019-05-08"
"2019-05-29"
"2019-03-27"
The code is not working properly . Can anyone let me know what is the mistake i am doing