Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7864619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:50:17+00:00 2026-06-02T23:50:17+00:00

I have a list: List<DateTime> timeStamp; Lets say that the list contains the following

  • 0

I have a list:

List<DateTime> timeStamp;

Lets say that the list contains the following DateTimes:

2006-09-07 11:46:09
2006-09-07 11:46:19
2006-09-07 11:46:20
2006-09-07 11:46:36

2006-09-07 11:47:49
2006-09-07 11:47:53
2006-09-07 11:48:02
2006-09-07 11:48:15
2006-09-07 11:48:29
2006-09-07 11:48:34

2006-09-07 11:54:29
2006-09-07 11:54:39
2006-09-07 11:54:49
2006-09-07 11:54:59

2006-09-07 11:56:19
2006-09-07 11:56:29
2006-09-07 11:56:39 

2006-09-07 11:58:29
2006-09-07 11:58:34
2006-09-07 11:58:45
2006-09-07 11:58:53

2006-09-07 12:00:29
2006-09-07 12:00:39
2006-09-07 12:00:45
2006-09-07 12:00:54
2006-09-07 12:01:03

Now, I want to calculate the total accumulated time. All of these times are in the same List, and the gaps represent a stop/start section. I also have no control over the interval of the timestamp. It could be 10 seconds, it could be 1 minute. Thanks for any and all help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:50:19+00:00Added an answer on June 2, 2026 at 11:50 pm

    Here’s a new answer if you can define the length of the gap:

    var length = timestamps
               .Zip(timestamps.Skip(1), (a, b) => b - a)      // pairwise entries and timespan
               .Where(gap => gap < TimeSpan.FromSeconds(180)) // ignore large gaps
               .Sum(x => x.TotalMilliseconds);                // total span in ms
    

    This works by zipping the list against itself so that entries that were next to each other are available for selection (ie the list is selected ‘pairwise’). Timespans are calculated from these, and large timespans (ie that intervals you want ignored) are filtered out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have list of rows that user select and i want to delete them,
I have a huge list of datetime strings like the following ["Jun 1 2005
I have a list of custom objects. These objects have 2 datetime properties on
I have a list of Foo's . Foo has a CreateDate of type DateTime?
I have List I want to sort Desc by Priority, which is int and
i have a list of buffers that i display into a telerik radchart. It
I have a table 'fvs_data' with a timestamp column that I have used for
I want to create a list of Task objects that is the most recent
I have the following column in my data frame: DateTime 1 2011-10-03 08:00:04 2
I have a table with a column that is a DATETIME in a SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.