C# calcuate date ranges from a list of dates.

Posted by nakulringshia on Stack Overflow See other posts from Stack Overflow or by nakulringshia
Published on 2010-05-08T16:50:00Z Indexed on 2010/05/08 16:58 UTC
Read the original article Hit count: 166

Filed under:
|

Hi

Given a list of dates (which may not be sorted), I want to build a list of date ranges -

E.g. Assuming MM/DD format,

Input - 5/1, 5/5, 5/6, 5/15, 5/7, 5/8, 5/19,5/20, 5/23

Output -

Date Range 1: 5/1 to 5/1
Date Range 2: 5/5 to 5/8
Date Range 3: 5/15 to 5/15
Date Range 4: 5/19 to 5/20
Date Range 5: 5/23 to 5/23

Basically, a range should be continuous.

Thanks

Nakul Ringshia

© Stack Overflow or respective owner

Related posts about c#

Related posts about date