I am hoping that someone can help me a SSRS Subscription/Report Query. I have a report that takes 2 date parameters as default startdate = 1st Date of the Current Month, enddate = today's date e.g. startdate = 01/05/2017 enddate = 17/05/2017.
Though these are default dates when the report is run you can also after the initial run change these dates to anything else that you want.
What I want to do is set up a subscription service that runs on 1st of the month and sends the report to a folder on the network.
What I want to do though is replace the startdate and enddate at the point the subscription is run with the startdate and enddate of last month e.g. on the 1st of May the startdate = 01/04/2017 and enddate = 30/04/2017.
What I thought I would do is create a stored procedure in my report with the relevant dates on it for all scenarios that I will need. Set the Last Month one's with default values from the procedure.
Now I can see all date parameters that I might need within the subscription set up but I cant see how I can change the default run time ones when the report is just run on a daily basis by a user to the ones I need it to run for the last month. I know I could just create another report to do this but it seems silly to have multiple reports with only the dates differing and I going forward I am likely to use this logic on other date ranges.
The initial code and idea came from this link "SQL Server: calculating date ranges"
Thanks
Hi R.Richards, since posting the initial query I have been testing a few things with Data Drive Subscription and I think that one of the issues may be due to date format. My report parameters are just set up as date/time but as stated I am wanting to use a function/procedure to call the relevant date splits. The code I am using is in the link that I posted to the original query but I can post it here as well if it helps. When using data driven, if I just use the date default in the report there appears to be no issue but when I select it from the function it errors, the function returns year/month/day timestamp but when I see my defaulted date in the parameter its day/month/year timestamp??
Thanks Phil
Related
I have a selection of SSRS report where the client has requested that there is a different reporting range for each schedule e.g. The daily schedule run Daily reporting on sales for the past day, the Weekly schedule to report on previous week etc. I am trying to use one "sales" report to do this and have different options for the "Start" date as a parameter that can be selected. I have set these up as "Available" values rather than a "Default" with the following:
Daily = =DateAdd("D",-1,Today())
Monthly = =DateAdd("M",-1,Today())
I have set up a scheduled for this report to run using the parameter and selected "Daily" but when this runs I get the following error message:
The subscription contains parameter values that are not valid.
And then if I look at the subscription settings, the "Start" parameter is completely blank forcing me to select Daily or Monthly again. If I were to instead set it up as a default value using one of those parameter mappings then it works absolutely fine. Is there a way to have these optional parameters, or am I going to be forced to create different Daily/Weekly/Monthly reports each with their own default parameters for the start times.
Note: When I debug the report with those parameters it runs absolutely fine, the issue is with the scheduled versions not keeping the parameters.
If you have access to data-driven subscriptions with your SSRS version, you can pass in multiple dates, emails, etc. This allows you to send out different versions of the report in one subscription.
Another option would be to add another parameter with the Daily/Weekly/Monthly option. Then have the default date use this parameter value to determine the date value. Then you could have 3 subscriptions on the same report each with their own interval selected.
I hope one of these options will work for you.
I am trying to get the graph working so that when you drill down to a certain group, you can choose if you want to look at it daily, weekly, etc. I set parameter up with a start date and a end date, but when I run the report nothing changes.
StartDate parameter
Series parameter
I have a report that returns basic rows of data. I need to filter this and only get data for yesterday. I was looking into adding a filter to the tablix, choosing the date field, setting operator value to =, and then using Today(), but cannot seem to manipulate Today() using -1 or anything similar.
Any other expression suggestion would be welcome.
Also, for the same dataset, I need to filter for yesterday based on one date filed as long as another date field is not the same date. example, amended date is yesterday, but created date is not the same.
There are a couple of ways of achieving this. You can do it via the filter using two filters, first > dateadd("d",-1,Today()) and second < Today(). But I would recommend using parameters in your SQL rather than doing it at the report stage. In your SQLs WHERE clause you can add
WHERE ...
And
[date field] BETWEEN #StartDate and #EndDate
Then you can create two Date/Time type parameters in your report #StartDate and #EndDate and use those to manipulate the data as needed. Then you can set the default for those parameters to be whatever you want and when running the report it will give you (or your end user) a calendar to pick whichever date range you/they like. Again if you wanted only "yesterdays" data you could set your default #StartDate to =dateadd("d",-1,Today()) and your #EndDate default to =Today() That way your extraneous data will be excised at the SQL level meaning you don't waste resources importing more data than you require and you don't have to mess about with changing the filters if you want a one off run of the report for a different date range.
I have a report in SQL Server 2008 Reporting Services (SSRS) that I'd like to schedule to run automatically for the previous dates (That Means this a Banking Related Report and the Transaction date is Today's Date ) I would like the Report to generate daily automatically for Yesteraday's date i.e. suppose Transaction date is 15-01-2012 I want to send yesterday s transaction date i.e. 14-01-2013 report daily to the customer.
Is it posible and how can I do this please explain.
Few steps here:
Set up the report to work with a default date parameter, and set the default expression to yesterday, e.g. =DateAdd(DateInterval.Day, -1, Today()).
Set the report to retrieve its Dataset based on the parameter.
Schedule the report through Report Manager and set the date parameter to use its default value, i.e. yesterday:
If you've never done it before, creating a subscription in Report Manager:
http://msdn.microsoft.com/en-us/library/ms189680.aspx
I have an (either or) situation in regards to parameters in SSRS 2008. I currently have my report working with a date range but I've been asked to add a drop down for the user to select the weekending date. I've got that drop down working but how can I switch between parameters (Date Range and the use of the Weekending Date drop down) for sending parameters to my report?
The way I allways fix this is by setting the parameters as nullable.
Then in my sql script I select all dates on the weekending date or between the daterange:
So whatever the user specifies, your sql script is filtered based on their parameters.
select *
from [table] t
where t.[date] = #WeekendingDate
or t.[date] is between #DateRangeFrom and #DateRangeTo
I usually handle this situation by creating an Internal Parameter(s) to sit between the UI and the query or stored procedure. The Internal Parameters are driven by expression depending on the user selection.
so lets say you want the user to either select a begin and end date range(Begin: 2012-01-01 End: 2012-01-31), or a month (Jan 2012).
If they select a value for Month. I convert that to an equivalent date range in the internal parameter expression. If they enter a date range I just pass through the begin and end values to the internal parameters.
Hopefully this makes sense. with a little work and imagination I think the approach can handle most scenarios.
One possibility would be to use the version control system of your choice to make another branch for the second report, change that one to use Week Ending, and then just make sure you merge changes every time you make a change to the main report.
I'm sure someone will come up with a cleaner way to handle it, though...