I have a table that has data for current year and previous year. The individual records in this tables represent each transaction that took place on each day of the year. There can be multiple records on each date.
I am also displaying data related to this table in an SSRS dashboard report. There are two parameters @StartDate and @EndDate being passed from this report. I need to write a SQL Server Stored Procedure that accepts a @StartDate and @EndDate paramenters.
The challenge I am facing here is, Based on the end date passed from the report, I need to get previous 8 weeks of data from current year. Also, the data from previous year for the same date ranges and display like a weekly breakdown comparison on an SSRS chart.
For example, If the End date on my report is 2016-09-21, I need to get data for previous 8 week ranges i.e.(9/15-9/21,9/8-9/14,9/1-9/7 and so on up to 7/28-8/3.) I also need to get data for the same date ranges in the previous year.
I also have to display the week date ranges on the X-axis of a chart on the SSRS report side.
Please let me know if I can provide any further details from my end. Thank You.