function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Hi,
I need to find Minimum date and maximum date from list of dates.Can anyone give me solution?
Regards
banu
If the list is an actual List<Date> collection, you can use the sort method on it.
extract element 0 from the sorted list for the smallest or earliest date, and select the list size -1 for the largest or latest date.
Here is a little sample code to show you how it works:
List<Date> dlist = new List<Date>(); for(integer i=0;i<100;i++){ dlist.add(date.newinstance(2011,1,1).adddays(-i)); } dlist.sort(); system.debug('\n\nsmallest date: '+dlist[0]); system.debug('\n\nlargest date: '+dlist[dlist.size()-1]);
If the list is an actual List<Date> collection, you can use the sort method on it.
extract element 0 from the sorted list for the smallest or earliest date, and select the list size -1 for the largest or latest date.
Here is a little sample code to show you how it works: