using T-SQL generate a weekly time frame table
Posted on 2011-02-18
I would like to generate a weekly time frame table which consists of 2 columns (start_day & end_day). start_day is ALWAYS Sunday, end_day is ALWAYS Saturday
The input for start_day is ALWAYS Sunday as well, but the input of end_day might not necessary be Saturday.
In the case of input of end_day is not Saturday, the query will automatically figure out the Saturday for that week.
Here is an example:
giving the start_day "2011-02-06" (it is Sunday) and end_day "2011-02-28" (it is not Saturday)
my T-SQL will generate a result like below
2011-02-27 2011-03-05 --> 3/5/2011 is the Saturday of the giving end_day ("2011-02-28"
Is there a good way to do this? thank you in advance.