Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 Date Validation Parameter

Author  Topic 

LOOKUP_BI
Constraint Violating Yak Guru

295 Posts

Posted - 2008-03-18 : 15:14:25
Hi Guys,

Here I am stuck with Date Validation.I have a report which displays certain information based on StartDate and EndDate parameter selected by user.Both parameters are of DateTime data type.Currently I have a query that displays customer information based on the startdate and enddate selected by user.All works well..Rather simple actually.

My Problem is How do I validate the date selected for both StartDate and EndDate are between '01/01/2008' and '12/31/2008'.If yes, then display report.Else Let user know to select date between Year range of 2008.Any ideas ?.....Pls advise me .....
I have to implement this on at least 20 reports.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-19 : 09:09:38
I dont think you can add any of custome validations when yu use the refault report viewer. To implement this functonality, you might have a develop a customised viewer for reports using .NET.
Go to Top of Page

LOOKUP_BI
Constraint Violating Yak Guru

295 Posts

Posted - 2008-03-19 : 09:59:58
Is there any other suggestions on how to limit the users selection to only dates with Year 2008? I cant use a drop down as the selection, but would be too long.

A team member has suggested thinking of a way to add some logic in the Report > Report Properties > Code in Layout Tab and there is also another suggestion on adding an If statment in each dataset that would validate startdate and enddate parameter before the query start's processig.Some thing like this

IF @StartDate > '01 JAN 2008' AND @EndDate <= '31 DEC 2008'
BEGIN
Select Name,Address from dbo.Customer where
convert(char(10), Date, 101)
BETWEEN @StartDate AND @EndDate
END
ELSE
BEGIN
Select 'Dates not valid' AS Name, '' AS Address
END
.

The deadline is close for my project and I need to find a solution for doing this.Maybe you could help me understand how both the above solutions would help.Any ideas are greatly appreciated.Thank You in Advance.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-03-19 : 13:08:32
What happens when this report is run next year and it is 2009 ?

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-20 : 10:26:11
Or you could create an internal parameter date and hardcode the desired value and use this in query to restrict the data returned
Go to Top of Page

LOOKUP_BI
Constraint Violating Yak Guru

295 Posts

Posted - 2008-03-27 : 11:52:50
Visakh,

Could you give me an example on how to hard code only "2008" dates to a report parameter, having datetime data type or would I need to use a string/txt data type.

What is the best method?

Jeff,

I need to find a way to get users only to be able to pick 2008 dates.No 2009 or 2007 dates.
Go to Top of Page
   

- Advertisement -