user2671286
user2671286

Reputation: 101

SSRS Date Time Parameter

enter image description hereI have an SSRS report that I would like to set the default end date to be 6 months prior to today's date and the start date to be 2 years prior to the end date. If I run it in September, End date would be March, next month End date should automatically update to April. How can I configure this in SSRS?

Upvotes: 0

Views: 3733

Answers (3)

Hank G
Hank G

Reputation: 36

Create the parameters, and set the Default values as below:

Start Date:=DateAdd(DateInterval.Month, -30, Today()))

End Date:=DateAdd(DateInterval.Month, -6, Today()))

Use these parameter values in the data set queries to filter out the results.

Upvotes: 0

Abhishek
Abhishek

Reputation: 2490

The below expression will work as per your need, you need to put these in the parameters default value section and opt for "specify values" -

StartDate =DateAdd(DateInterval.Month,-30,Now())

EndDate =DateAdd(DateInterval.Month,-6,NOW())

Also choose the parameters as Date/Time. Below Snapshot to show the difference I chose Start Date as Date/Time and End Date as Text enter image description here

Upvotes: 0

Eitan K
Eitan K

Reputation: 837

Try this:

Start Date:=DateAdd(m, -30, GetDate())

End Date:=DateAdd(m, -6, GetDate())

Here are great references:

SQL Server DATEADD() Function

SQL Date Functions

Upvotes: 0

Related Questions