how to work with parameters

I have installed sql server 2008 reporting services and I already have query, but I want to add parameters to that query in report, and also have date in my query if user dont enter date , it will be default to ..
here my query,
select lastname, firstname, datestarted from tblCustomer where
datestarted > GetDate()- 45

and I want to add a parameter to the report, that datestarted, for user to get prompted to enter datestarted, if it is left empty, that time it will be GetDate() - 45 defaulted..
1jawsAsked:
Who is Participating?
 
HadushCommented:
Sorry, I hit submit before I attached the images

DataParameter1.bmp
ChangeDataTypeToDateTime.bmp
DeafultValuesToToday.bmp
0
 
Kevin CrossChief Technology OfficerCommented:
0
 
HadushCommented:
1. you need to change the query to take parameter date (say startDate)
select lastname, firstname, datestarted from tblCustomer where
datestarted > @StartDate()- 45
2. Go to Reports-->Report parameters --> (you will see StartDate parameter listed )
Make sure the datatype is DateTime so that your users will see a calender with current date as default
Fill the report parametrs widnow as shown in the picture and make sure the default to Non-query   (=Today)
 
Let me know if this helps

DateParameter.bmp
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
HadushCommented:
Correction on the query, you don't need the parenthsis on the startDate
select lastname, firstname, datestarted from tblCustomer where
datestarted > @StartDate- 45
0
 
1jawsAuthor Commented:
thank you so much both, I am still having trouble because are we viewing same reporting tool? I have sql server 2008 2.0 report builder
 on the left side I have Built in Fields
                                    Parameters
                                    Images
0
 
HadushCommented:
In 2008 is a bit different environtment and here are the steps for that:
1. In the report data pane expand parameters (shown in fig one) and double click the parametername(@startDate)
2. General tab change the data type to Date/Time from the Datatype Drop down list
3. Default values tab  check the Specify values radio butten and under value slect the expression sign (fx) and put =Today
and ok, ok , ok
0
 
1jawsAuthor Commented:
THank you I worked! if I want to add for example country parameter I just do it the same way, but I want if user leaves empy that textbox when prompted at the report , I wanted to pull all the countries, how can I do that?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.