on 05-21-2015 1:50 PM
I have been trying to find a way around this with no success, I have a SP that takes a start and end time as input parameters, what I want to do is to pass variables to this SP based on the ‘Relative Date’ selected by the user e.g Today, Yesterday, Last Week
Here is what I’m trying to do on Crystal with no success, I would appreciate help on what I might be doing wrong or if the is a better alternative method
DECLARE @YStartDate datetime
DECLARE @YEndDate datetime
SET @YStartDate = dateadd(day, datediff(day, 1, getdate()), 0) + '00:00:00'
SET @YEndDate = dateadd(day, datediff(day, 1, getdate()), 0) + '23:59:59'
DECLARE @TStartDate datetime
DECLARE @TEndDate datetime
SET @TStartDate = dateadd(day, datediff(day, 0, getdate()), 0) + '00:00:00'
SET @TEndDate = dateadd(day, datediff(day, 0, getdate()), 0) + '23:59:59'
Case '{?RelativeDate}'
When ‘Today’ then EXEC PDV_UserWorkGroupInterval @TStartDate, @TEndDate
When 'Yesterday' Then EXEC PDV_UserWorkGroupInterval @YStartDate, @YEndDate
When 'DateRange' Then CONVERT(datetime, {?StartDate})
END
The only way you'll be able to calculate this in the report in order to send it to the stored proc will be to put the stored proc into a subreport and pass the parameters in from the main report. There is no way to calculated this in the main report prior to calling the stored proc.
If you don't need any other subreports in your report, this should not be a problem. You'll use a table or command that returns a single record (I like to use something like "Select GetDate()" for SQL Server or "Select Sysdate from dual" for Oracle). Put the parameters in the main report. Then calculate the actual start and end date in separate formulas based on the parameter. Use these formulas to link to the store proc parameters in the subreport.
-Dell
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Guys, this worked beautifully
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Dell and Abhi,
I'm making some progress with your help, i will let you know the outcome shortly
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Melinyaniso,
For the 'Date Range' value, does the user need to select the Start Date and End Date from a Range prompt?
I guess you need two prompts - one that prompts for the verbiage and a Range prompt that drives the report only when the user choose 'Date Range' in the first prompt.
If you can confirm this, I can post another way to do this.
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What Dell suggested is what I was going to suggest too!
You'll need:
- A Main Report with the two prompts
- Two formulas that return start and end dates based on the prompt selection
- The original report added as a Subreport with these two formulas linked to the Start and End prompt from the Subreport's Stored procedure.
-Abhilash
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.