You need to sign in to do that
Don't have an account?

Compare dates in salesforce
Lets say i have four dates , how to find which one is the latest date using apex ?
or
If we add dates to a List of dates can we sort ?
or
If we add dates to a List of dates can we sort ?
If you get the answer, please mark it as the correct answer. It will be a help to others who are facing the same problem later.
Thanks for your reply , it solves my problem upto some extend ,This approach actually having lot of if else .
I just found another approach which omits all if and else condition hope u like it :
List<Date> lisd = new List<Date>();
Date t1= Date.today();
Date t2 = Date.today() - 2;
Date t3 = Date.today() + 3;
lisd.add(t1);
lisd.add(t2);
lisd.add(t3);
lisd.sort();
System.debug('Latest Date'+ lisd[2]);