There are many examples of user defined table functions generating the series of dates(times) between two specified values. Usually, in OLAP you can see a table filled by the date/time series, too. Such table avoid to generate the values "on the fly".
However, in some cases you may be unable to use an UDF or a table. Fortunately, "pure SQL" method still works.
Suppose, the start and finish dates are specified as entry parameters. The transact SQL code below generates the series "moth by month".
Clearly, an index build on only one column of the bit type is useless because the selectivity is poor (50% of a table in average). However, when a table has several columns of the bit type, the composite index may be efficient.
For the test example, we'll create a table and fill it with random data.