By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,640 Members | 1,363 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,640 IT Pros & Developers. It's quick & easy.

Average items in a List for specific time interval

P: 2
I have a List of items (type: double). Each item has it's own timestamp.

Now I need to calculate the average of items in a past interval. For example: Average of all items starting from 20 minutes ago until 10 minutes ago. Can someone suggest me how do I go about it?

Thanks a lot!
Mar 13 '13 #1
Share this Question
Share on Google+
3 Replies


10K+
P: 13,264
Where are the times for each item stored?

Average = Total/Count

Are you able to count how may records there are in that period?
Are you able to add the totals of the records in that period?
Mar 13 '13 #2

P: 2
Good question and sorry for missing out on that detail.

Yes, I have a count of records from time = 0 to DateTime.Now().

I can also add any of these records.

My confusion is how to fetch items from my List for a specific time interval, say average of 5 minutes, from 10 minutes ago.
Mar 13 '13 #3

Rabbit
Expert Mod 10K+
P: 12,382
Loop through each item and check to see if the time is between the interval you're looking at.
Mar 13 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.