Getting Month Numbers between two dates in T-SQL

I literally had to spend around an hour to crack this code, with some little help from my best geek friend, GOOGLE, of course. Issue is this: I wanted to get Month in Numbers (Jan = 1, Feb = 2, etc.) that exist between two dates. For instance, if my date range is 1-Jan-2011 to 31-Mar-2011, then I should find and retrieve the months Jan, Feb and Mar as 1, 2 and 3 respectively. After much much toiling and reading some stuff online, the following is what I got for myself: ----- ; WITH Numbers (Number ...read more
Related
Recommended