Search code examples
datevisual-studio-2012parametersssrs-2012default-value

SSRS: Default Values for StartDate Parameter Based on EndDate Parameter


I'm working with SSRS and using Visual Studio 2012.

I have two parameters StartDate and EndDate and I configured default values for each.

The default values currently for both are the following:

StartDate: =DateAdd("d",-(Day(today)-1), Today)

EndDate: =Today() - 1

I want the values to bring in: StartDate: 1/1/2017 EndDate: 1/31/2017

Basically, I want EndDate to be the previous day (e.g. EndDate for today would be 1/31/2017 since today is 2/1/2017.)

And then for StartDate, I want that to be the first day of the month that EndDate pulls in (e.g. since EndDate pulled in 1/31/2017, the StartDate should pull in 1/1/2017.)

However, with the current parameters in place, StartDate pulls in 2/1/2017 and EndDate pulls in 1/31/2017.

How do I get StartDate to pull in the 1st day of the month based on the value of EndDate?


Solution

  • For StartDate you can use:

    =DateSerial(Today.AddDays(-1).Year,
    Today.AddDays(-1).Month,
    1)