Loop months between a time span yyyy-mm and yyyy-mm
These are all good sugestions but to my taste not linq-ish enough and not really reusable. Since I don't like writing the same code serval times you might want to encapsulate some of this logic for later use.



You can extract two pieces. First you have a date-time range so create a Range struct. Here's a very simple one (as an example without any parameter validation - actually T should be IComparable so you can assure the range is valid).

readonly struct Range&lt;T&gt;
{
    public Range(T min, T max)
    {
        Min = min;
        Max = max;
    }

    public T Min { get; }

    public T Max { get; }
}


Then you are interpolating between min and max. Put this in an extension that will consume a Range and do the rest:

public static IEnumerable&lt;T&gt; Interpolate&lt;T&gt;(this Range&lt;T&gt; range, Func&lt;T, T&gt; next) where T : IComparable
{
    var current = range.Min;
    while (current.CompareTo(range.Max) &lt;= 0)
    {
        yield return (current = next(current));
    }
}


Now all you need is to parse the date so how about one more helper for that too?

static class Range
{
    public static Range&lt;DateTime&gt; FromDateTime(string min, string max, string format)
    {
        return new Range&lt;DateTime&gt;(
            DateTime.ParseExact(min, format, CultureInfo.InvariantCulture),
            DateTime.ParseExact(max, format, CultureInfo.InvariantCulture)
        );
    }
}


And we're ready to go. Create a range and let the extension work.

var range = Range.FromDateTime("2015-02", "2018-11", "yyyy-MM");
range.Interpolate(d =&gt; d.AddMonths(1)).Dump();


Now you have nice components that you can use in many more places and maybe in several projects.