I need to create user-defined function with two incoming parameters that returns a table. First parameter @start Date type. Second parameter @end Date type.
There is no any application to generate it. I just need a result in SQL server. I am looking for a simple T-SQL solution. SQL 2012 works for me.
Select * from Dbo.function_name(‘Oct 03, 2013’, ‘Nov 21, 2013’)
It has to return calendar table like this.
Su Mo Tu We Th Fr Sa
3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21
There is no simple solution. Having taken this on as a challenge to do while (whiskyglass.Contents.Any()), this is what I got.....
It's not quite right - the output is a date rather than an integer and it doesn't behave nicely at the year boundary, but it might suffice for a purely T-SQL solution.
Added a copy to SQL Fiddle http://sqlfiddle.com/#!3/98ebe/2