I finally found out a way for doing this by creating a new stored procedure which will be run in SSRS daily.
This stored procedure will provide the values for the input parameters required by the other stored procedure 'spCalculateSomething' for working based on the quarterly conditions:
CREATE PROCEDURE automated
AS
BEGIN
Declare @startDate1 DateTime;
Declare @endDate1 DateTime;
Declare @month int;
set @endDate1=GETDATE();
set @month= DATEPART(mm,Getdate());
if(@month=1 or @month=2 or @month=3)
begin
set @startDate1= '01/01/' + CONVERT(VARCHAR(4), DATEPART(yy, getUTCDate()))
set @endDate1='03/31/'+ CONVERT(VARCHAR(4), DATEPART(yy, getUTCDate()))
end
else if (@month=4 or @month=5 or @month=6)
begin
set @startDate1='04/01/'+ CONVERT(VARCHAR(4), DATEPART(yy, getUTCDate()))
set @endDate1='06/30/'+ CONVERT(VARCHAR(4), DATEPART(yy, getUTCDate()))
end
else if (@month=7 or @month=8 or @month=9)
begin
set @startDate1='07/01/' + CONVERT(VARCHAR(4), DATEPART(yy, getUTCDate()))
set @endDate1='09/30/'+ CONVERT(VARCHAR(4), DATEPART(yy, getUTCDate()))
end
else if (@month=10 or @month=11 or @month=12)
begin
set @startDate1='10/01/'+ CONVERT(VARCHAR(4), DATEPART(yy, getUTCDate()))
set @endDate1='12/31/'+ CONVERT(VARCHAR(4), DATEPART(yy, getUTCDate()))
end
EXEC Poin.[dbo].[spCalculateSomething]
@startDate = @startDate1,
@endDate = @endDate1
END
The reason this will work for the above questions of having end date extended to 15 days is because even if you run this in first quarter, lets say 15th february, the endDate of 31st march will not affect as the records in our main table where processing is going on will be till 15th february. So this works for me to run every day for a specific quarter based on the month it is run.
Dynamic SSRS Subscriptions
? – Tab Alleman