I have dates as a list in the following format:
09-2012,10-2012,01-2013
What will be the better way to access the minimum and maximum dates from the list?
I'm not really sure which is faster. Here is my list-only-solution below , or you could convert the list to an array and work with that.
This does the job though:
<CFSET dates = "" />
<CFLOOP list="09-2012,10-2012,01-2013" index="date">
<CFSET dates = listappend(dates,DateFormat(createDate(listlast(date,"-"),listfirst(date,"-"),1), "yyyy-mm-dd")) />
</CFLOOP>
<CFSET dates = listsort(dates,"numeric") />
<CFSET min_date = listfirst(dates) />
<CFSET max_date = listlast(dates) />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With