What are advantages of your code? What if intervals are: (2013-01-01, 2013-06-31) and (2013-07-01, 2013-12-31) - your code will make 365 iterations and store 365 values on list, my will store only 4 values and make 6 (2+4) iterations. My code has O(nlogn) complexity (where n is number of intervals), your code has O(n), but in your case n is number of days which is more more greater than number of intervals :)