Solved

SSRS Parameter in Query

Posted on 2008-10-21
4
495 Views
Last Modified: 2012-05-05
This below query runs GREAT.  But, for reporting purposes, I created a Parmeter in SSRS called "Date" and I can't seem to figure out how to have this SELECT query base its Date values off of the value the user will put in for this parameter.    I thought it would be something like this, but it doesn't seem to work:

SELECT     CHECKMAST.LEVEL1ORG, CHECKMAST.BANKACCTNUM, CHECKMAST.DATEPROCESSED, CHECKMAST.VOIDPOSTDATE, CHECKMAST.CHECKNUM,
                      CHECKMAST.CHECKAMT, CHECKMAST.CHECKDATE, CHECKMAST.STATUS
FROM         AP.CHECKMAST CHECKMAST
WHERE     (CHECKMAST.LEVEL1ORG = 2000) AND (CHECKMAST.BANKACCTNUM = '726252') AND
                      (CHECKMAST.DATEPROCESSED >= (@DATE)) AND (CHECKMAST.DATEPROCESSED < (@DATE)) OR
                      (CHECKMAST.LEVEL1ORG = 2000) AND (CHECKMAST.BANKACCTNUM = '726252') AND (CHECKMAST.VOIDPOSTDATE >= (@DATE))
                       AND (CHECKMAST.VOIDPOSTDATE < (@DATE))
SELECT     CHECKMAST.LEVEL1ORG, CHECKMAST.BANKACCTNUM, CHECKMAST.DATEPROCESSED, CHECKMAST.VOIDPOSTDATE, CHECKMAST.CHECKNUM, 
                      CHECKMAST.CHECKAMT, CHECKMAST.CHECKDATE, CHECKMAST.STATUS
FROM         AP.CHECKMAST CHECKMAST
WHERE     (CHECKMAST.LEVEL1ORG = 2000) AND (CHECKMAST.BANKACCTNUM = '726252') AND 
                      (CHECKMAST.DATEPROCESSED >= { ts '2008-10-17 00:00:00' }) AND (CHECKMAST.DATEPROCESSED < { ts '2008-10-18 00:00:00' }) OR
                      (CHECKMAST.LEVEL1ORG = 2000) AND (CHECKMAST.BANKACCTNUM = '726252') AND (CHECKMAST.VOIDPOSTDATE >= { ts '2008-10-17 00:00:00' })
                       AND (CHECKMAST.VOIDPOSTDATE < { ts '2008-10-18 00:00:00' })

Open in new window

0
Comment
Question by:chrisryhal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 12

Expert Comment

by:jgv
ID: 22768142
In the crystal code the dates are hardcoded and in each of the ranges there is a one day difference (2008-10-17 to 2008-10-18). Your SQL query is using the same parameter on both sides of the range (ie: 2008-10-17 to 2008-10-17). For this to work like the crystal code you will either need to create another date parameter (ie: EndDate) or you need to add 1 day to the date the user selects.
0
 
LVL 2

Author Comment

by:chrisryhal
ID: 22768217
I was just going to add one day to the date the user selects.

I can't figure out how to tell this SELECT statement though to use the Parameter.  What would it look like?
0
 
LVL 12

Accepted Solution

by:
jgv earned 500 total points
ID: 22768286
You have the parameter setup in the query properly but the brackets are unnecessary (you only need these when you are using an IN operator). You can use the DateAdd function to add a day to the parameter from within the query. Example:
(CHECKMAST.VOIDPOSTDATE >= @DATE)
                       AND (CHECKMAST.VOIDPOSTDATE < DATEADD(day, 1, @DATE))

0
 
LVL 2

Author Closing Comment

by:chrisryhal
ID: 31508323
Thanks for the help.    Perhaps you may have some insight on this question?  http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL-Server-2005/Q_23840892.html
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, In my previous Article  (http://www.experts-exchange.com/Database/Reporting/A_15199-Introduction-to-Microstrategy.html)I discussed some basic understanding of Microstrategy that how we can get in Intro of Microstrategy (MSTR). Now it's tim…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question