How to group a period of time into yearly periods ? (split timespan into yearly periods)
- by user315648
I have a range of two datetimes:
DateTime start = new DateTime(2012,4,1);
DateTime end = new DateTime(2016,7,1);
And I wish to get all periods GROUPED BY YEAR between this period. Meaning the output has to be:
2012-04-01 - 2012-12-31
2013-01-01 - 2013-12-31
2014-01-01 - 2014-12-31
2015-01-01 - 2015-12-31
2016-01-01 - 2016-07-01
Preferably the output would be in IList<Tuple<DateTime,DateTime>> list.
How would you do this ? Is there anyway to do this with LINQ somehow ?
Oh and daylight saving time is not absolutely critical, but surely a bonus.
Thanks!