Filtering data in an Array

Hi all,

I have an array that has 30 date objects. The date objects are indexed in the array from minimum date value to maximum date value. What I would like to do is retrieve only 7 dates from the array. Out of the 7, the first one should be the minDate and the last should be the maxDate, with 5 dates in the middle. The 7 numbers should increment evenly from the minDate to the maxDate. How would I accomplish this? Hope I was clear.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michel PlungjanIT ExpertCommented:
Here is the first and last part
toneDigitalAuthor Commented:
Thanks mplugjan!

is it possible to show an entire solution? I'm really am not getting this. Would you know how to do this with actionscript?


Michel PlungjanIT ExpertCommented:
1. I do not do actionscript
2. You need some kind of math to find some kind of median values

The link I gave you shows how to sort a date array
Michel PlungjanIT ExpertCommented:
Okay - seems you found a solution elsewhere. Please share when you have a complete solution.
toneDigitalAuthor Commented:
Sorry for very late reply. I found a solution. If there is a better one, please suggest. Thanks.

var midpt = Math.ceil((my_array.length-2)/2);
var apt = Math.floor(midpt/3);
var off = (mid%3);

trace(my_array[(off>3) ? apt+1 : apt]);
trace(my_array[(off>1) ? midpt-apt : midpt-apt-1]);
trace(my_array[(off>0) ? midpt+apt : midpt+apt+1]);
trace(my_array[(off>2) ? my_array.length-1-apt : my_array.length-1-apt-1]);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.