Average items in a List for specific time interval

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ambguy
    New Member
    • Mar 2013
    • 2

    Average items in a List for specific time interval

    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!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    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?

    Comment

    • ambguy
      New Member
      • Mar 2013
      • 2

      #3
      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.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Loop through each item and check to see if the time is between the interval you're looking at.

        Comment

        Working...