We help IT Professionals succeed at work.

DATEDIFF RESULT IN VARIABLE AND USED IN SSRS EXPRESSION

turaks
turaks asked
on
Hello,

can someone please tell me how to put datediff results in a variable in a stored procedure and call it from an ssrs textbox .

e.g
1.  in stored procedure:

select,column1,column2 , salesprice,
@datediffresult = datediff(dd,date1,date2)  from table

2. in SSRS Expression
=sum(iif(@datediffresult >=1 and <=7), (Fields!salesprice.value)

I know that the above is not the right way to do it but does anyone have any idea how?  thanks
Comment
Watch Question

Sr. BI  Developer
Commented:
If I understand correctly, From looking at your query, the SP won't be your solution.

You have 2 options:

You would create a view or even inline SQL inside the SSRS data-set to bring the results.
And use the field in the SSRS expression.

OR

You can even use the datediff function in SSRS expression, or as a computed column in the dataset.

Let me know if you need any more clarifications.

Author

Commented:
Thanks huslayer.  I have tried the datediff function in the expression but i have to do it for 12 textbox expressions such as:
12 11 10  9    8 7 6   5 4 3 2 1 0 -1  -2  -3  -4  -5   -6 -7 -8  -9  -10 -11 -12

Each number represents a textbox.  To use the datediff function in each textbox is taking to long to process.  

Please can you use an example of a computed column in the dataset?

Thanks
Jason YousefSr. BI  Developer

Commented:
Hi,
Just right click on the dataset name and select add calculated field...
that would be your best bet.

 1

Author

Commented:
Thanks. I will try this.
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.