Nice work, R2ro! It seems that your function is the best, so far. Here are some timings (in ms) for the three versions (counting the rows in the result, for the dates between Jan 1, 2006 and Jan 31, 2307):
Peter | Razvan | R2ro |
1906 | 1670 | 766 |
2076 | 2846 | 796 |
830 | 1653 | 876 |
906 | 610 | 766 |
860 | 1703 | 873 |
3170 | 2846 | 703 |
As you can see, on my system, the timings are varying strangely, but on average, your method seems to be the best.
Razvan