0

I'm creating a report (in report builder 3.0) containing 3 parameters @Name, @StartDate and @EndDate - pretty straight forward.

Now the report reader wants the possibility to use a fourth parameter, @Year. In theory this parameter should set @StartDate and @EndDate when chosen.

For instance, a reader chooses '2012' in @Year and then @StartDate and @EndDate are automatically populated with '01-01-2012' and '31-12-2012'

How is this possible?

2 Answers 2

2

Cant you create two new variables @Startdate and @Enddate in your SQL query from the @Year parameter. So it will work as you need.

@Startdate = convert(datetime, @year+'-01-01', 120)
@Etartdate = convert(datetime, @year+'-12-31', 120)
1
  • I'm not sure sure this would work if I want the reader to either choose a year using Year or specific date using StartDate and EndDate ? Dec 13, 2012 at 9:07
1

To add to Pradeeshnarayan's answer.

The only way to achieve this you have to add two hidden parameters that decide if the year is entered then default to the whole year or if not then default to the selected start and end dates.

E.G.:

@h_Startdate = IIf(@year=Empty, @Startdate, convert(datetime, @year+'-01-01', 120))
@h_Enddate = IIf(@year=Empty, @Enddate, convert(datetime, @year+'-12-31', 120))

Good question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.