user3735855
user3735855

Reputation: 144

SSRS parameter default to most recent 1st April

I have a requirement for an SSRS parameter that will be for a start date of the most 1st April, so today it will report from 1/4/2015 with 10 weeks data, but after the 1/4/16 it will default to 1/4/16.

Can anyone help with this please?

I can find most recent month, or current month etc, but this one is a little tricky. Thankyou.

I am using SQL Server 2012 and Visual Studio 2010

Upvotes: 0

Views: 778

Answers (1)

Sébastien Sevrin
Sébastien Sevrin

Reputation: 5405

You could use the following expression:

=IIF(Today() >= DateSerial(Year(Today()), 4, 1), DateSerial(Year(Today()), 4, 1), DateSerial(Year(Today()) - 1, 4, 1))

The idea is to check if the 1st of April of the current year has been reached (Today() >= DateSerial(Year(Today()), 4, 1)).

  • If yes, take the 1st of April of the current year: DateSerial(Year(Today()), 4, 1)
  • If no, take the 1st of April of the previous year: DateSerial(Year(Today()) - 1, 4, 1)

Upvotes: 1

Related Questions