SSRS 2008 Date Comparison Expression

  • Hi

    I have date input parameters, @From_Date and @To_Date.

    If From_Date = 01 August 2014 and To_Date = 30 September 2014 and I run my report, I want to get results "Results From 1 Aug 2014 to 30 Sep" as part of my header. However if the input parameters it's from 1 September 2014 to 30 September 2014 I want to get "Results for Sep 2014".

    I've been searching expression to work around this and I think I will have;

    =IIF(Format(Parameters!Report_From_Date.Value, "MMM") = Format(Parameters!Report_From_Date.Value, "MMM"), Globals!ReportName & " from " & Format(Parameters!Report_To_Date.Value, "MMM"),"Nope")

    as my starting point, then from this I need test the month I think, from there I'm getting confused.

    Please help

  • your expression will fail if the years changes

    something like this

    From Date = 01 September 2013

    To Date = 30 September 2014

  • you need something like (Assumption is the parameters are for DateTime Type).

    = IIF(

    DateSerial(Year(Parameters!Report_From_Date.Value), Month(Parameters!Report_From_Date.Value), "1").AddMonths(1).AddDays(-1)

    =

    DateSerial(Year(Parameters!Report_To_Date.Value), Month(Parameters!Report_To_Date.Value), "1").AddMonths(1).AddDays(-1)

    ,1,0)

    it will return '1' for equal, and '0' if not,

    Explanation:

    getting the month & year from the report parameters, calculate the Last date of the month of From Date parameter & To Date parameter, if they are equal then value will '1', else '0'.

    Hope it helps.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply